29. IOS系统原生富文本 自定义Label颜色
2015-09-01 17:20
453 查看
UILabel* lbl = [[UILabel alloc] init];
NSString* str = [NSString stringWithFormat:@"%@ %@", repeat, item.remember];
NSMutableAttributedString* aStr = [[NSMutableAttributedString alloc] initWithString:str];
[aStr addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
NSFontAttributeName,
[UIColor blackColor],
NSForegroundColorAttributeName,
nil]
range:[str rangeOfString:repeat]];
[aStr addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
NSFontAttributeName,
RGBCOLOR(188, 188, 188),
NSForegroundColorAttributeName,
nil]
range:[str rangeOfString:item.remember]];
lbl.attributedText = aStr;
NSString* str = [NSString stringWithFormat:@"%@ %@", repeat, item.remember];
NSMutableAttributedString* aStr = [[NSMutableAttributedString alloc] initWithString:str];
[aStr addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
NSFontAttributeName,
[UIColor blackColor],
NSForegroundColorAttributeName,
nil]
range:[str rangeOfString:repeat]];
[aStr addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
NSFontAttributeName,
RGBCOLOR(188, 188, 188),
NSForegroundColorAttributeName,
nil]
range:[str rangeOfString:item.remember]];
lbl.attributedText = aStr;
相关文章推荐
- IOS第17天(2,Quartz2D图片剪裁变圆行图,和截屏图片)
- 23.iOS学习笔记(十四)——发短信
- 24. iOS中文网址路径转换URLEncode
- 22.IOS开发中(null)与<null>的处理
- Ios 多国语言的使用(已汉语和英语为例)
- IOS第17天(1,Quartz2D图片水印)
- ios原生二维码扫描
- iOS CGAffineTransform详解
- 16.IOS 新消息通知提示-声音、震动
- IOS第16天(5,Quartz2D雪花)
- IOS第16天(4,Quartz2D柱状图)
- IOS第16天(3,Quartz2D饼图)
- IOS第16天(2,Quartz2D下载进度条)
- 14.IOS中系统唯一标识ID
- iOS KVC,KVO
- 4.极光推送解释的iOS本地通知
- 5.iOS 7 Background Remote Notification
- 2.iOS苹果推送-一些示例代码和注意的问题
- 1.iOS中的系统通知 自定义推送声音
- IOS开发-视频,音频,录音简单总结