设置label上文字显示不同大小、颜色、字体类型
2017-10-31 10:26
1016 查看
bottomS = @"注意:\n\n1.所有所有;\n\n2.标余额;\n\n3.不可退款。";
NSMutableAttributedString *noteStr = [[NSMutableAttributedStringalloc]
initWithString:bottomS];
// 需要改变的第一个文字的位置
NSUInteger firstLoc = [[noteStrstring]
rangeOfString:@"3"].location;
// 需要改变的最后一个文字的位置
NSUInteger secondLoc = [[noteStrstring]
rangeOfString:@"。"].location+1;
// 需要改变的区间
NSRange range =
NSMakeRange(firstLoc, secondLoc - firstLoc);
// 改变颜色
[noteStr addAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor]
range:range];
// 改变字体大小及类型
// [noteStr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-BoldOblique" size:27] range:range];
// 为label添加Attributed
[self.bottomTextsetAttributedText:noteStr];
NSMutableAttributedString *noteStr = [[NSMutableAttributedStringalloc]
initWithString:bottomS];
// 需要改变的第一个文字的位置
NSUInteger firstLoc = [[noteStrstring]
rangeOfString:@"3"].location;
// 需要改变的最后一个文字的位置
NSUInteger secondLoc = [[noteStrstring]
rangeOfString:@"。"].location+1;
// 需要改变的区间
NSRange range =
NSMakeRange(firstLoc, secondLoc - firstLoc);
// 改变颜色
[noteStr addAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor]
range:range];
// 改变字体大小及类型
// [noteStr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-BoldOblique" size:27] range:range];
// 为label添加Attributed
[self.bottomTextsetAttributedText:noteStr];
相关文章推荐
- iOS开发~设置label上文字显示不同大小、颜色、字体类型
- iOS 开发~设置label上文字显示不同大小、颜色、字体类型
- 应用键横竖屏切换;label中显示图片;不同类型设备适配的代码;UIWebView字体大小、字体颜色、背景色的设置;
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 同一label显示不同颜色,不同大小字体
- Label显示不同颜色、字体的文字
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- edit控件中如何设置字体的颜色,并把一行文字设置成不同大小。
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- TextView内容设置显示不同的字体颜色和不同的字体大小
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- UIButton 文字显示位置设置 字体的大小设置 字体的颜色设置 注意事项
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 五月 25th, 2012设置UIButton的文字显示位置、字体的大小、字体的颜色
- ios 设置label 不同字体大小颜色