iOS -多字体混合
label 加下划线
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 100)];
label.backgroundColor = [UIColor redColor];
label.numberOfLines = 3;
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"您的待办业务条fasdfasdfosadfjasdkljfklasjklfjasdlkjfklasdjklfjalskdjflkadsj"]];
NSRange contentRange = {0,[content length]};
[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
label.attributedText = content;
[self.view addSubview:label];
设置 大小不同的字体
NSString * stra = [NSString stringWithFormat:@"0 %.2lf 0",[straaa doubleValue]];
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:stra];
[str addAttribute:NSFontAttributeName value: kFontSize_24 range:NSMakeRange(0, 2)];
[str addAttribute:NSFontAttributeName value: kFontSize_100 range:NSMakeRange(2, str.length - 4)];
[str addAttribute:NSFontAttributeName value: kFontSize_24 range:NSMakeRange(str.length - 2, 2)];
[str addAttribute:NSForegroundColorAttributeName value: kColorBackground range:NSMakeRange(str.length - 2, 2)];
lable1.attributedText = str;
posted on 2016-03-29 20:28 🌞Bob 阅读(179) 评论(0) 编辑 收藏 举报