label(也可以说字符串)上不同颜色 和 不同大小 的设置
2016-09-19 14:07
204 查看
UILabel * buyLabel = [[UILabelalloc]
initWithFrame:CGRectMake(10, purchaseBtnY, purchaseBtnW, purchaseBtnH)];
buyLabel.textAlignment =NSTextAlignmentCenter;
buyLabel.font = [UIFontsystemFontOfSize:13.0];
buyLabel.textColor = [UIColorblackColor];
NSString * buyLabelText =
@"我要学习开发求指导,来呀,造作啊";
NSRange range = [buyLabelText
rangeOfString: @"求指导"];
NSMutableAttributedString * str = [[NSMutableAttributedStringalloc]
initWithString:buyLabelText];
[str addAttribute:NSForegroundColorAttributeNamevalue:[UIColor redColor]range:range];
[str
addAttributes:
@{NSForegroundColorAttributeName: [UIColorcyanColor]}range:NSMakeRange(range.location+
range.length, 3)];
[str addAttribute:NSFontAttributeNamevalue:[UIFontsystemFontOfSize:15]range:range];
buyLabel.attributedText = str;
initWithFrame:CGRectMake(10, purchaseBtnY, purchaseBtnW, purchaseBtnH)];
buyLabel.textAlignment =NSTextAlignmentCenter;
buyLabel.font = [UIFontsystemFontOfSize:13.0];
buyLabel.textColor = [UIColorblackColor];
NSString * buyLabelText =
@"我要学习开发求指导,来呀,造作啊";
NSRange range = [buyLabelText
rangeOfString: @"求指导"];
NSMutableAttributedString * str = [[NSMutableAttributedStringalloc]
initWithString:buyLabelText];
[str addAttribute:NSForegroundColorAttributeNamevalue:[UIColor redColor]range:range];
[str
addAttributes:
@{NSForegroundColorAttributeName: [UIColorcyanColor]}range:NSMakeRange(range.location+
range.length, 3)];
[str addAttribute:NSFontAttributeNamevalue:[UIFontsystemFontOfSize:15]range:range];
buyLabel.attributedText = str;
相关文章推荐
- iOS 给label一部分字符串设置不同颜色
- iOS开发~设置label上文字显示不同大小、颜色、字体类型
- ios 设置label 不同字体大小颜色
- SpannableStringBuilder设置字符串不同颜色和大小
- 应用键横竖屏切换;label中显示图片;不同类型设备适配的代码;UIWebView字体大小、字体颜色、背景色的设置;
- 自定义的Label,可以设置同一Label字体的大小不同,颜色不一
- 设置label上文字显示不同大小、颜色、字体类型
- label显示不同大小、颜色的字符串
- iOS 开发~设置label上文字显示不同大小、颜色、字体类型
- iOS开发 label上显示不同颜色不同大小的字
- gtk 设置标签(label)里字体的大小 颜色等属性的方法
- IOS 给Label添加下划线,删除线,不同的颜色和大小
- edit控件中如何设置字体的颜色,并把一行文字设置成不同大小。
- iOS设置Label上显示不同字体大小
- iOS设置同一个Label的不同颜色的字体
- android 一个 textview 设置不同的字体大小和颜色
- iOS 界面上绘制不同字体 颜色 大小的字符串
- iOS label button等设置不同颜色的标题
- iOS 设置Label中特定的文字大小和颜色