第三十三篇、富文本 NSMutableAttributedString
2016-09-21 14:23
288 查看
// 设置颜色等 NSMutableDictionary *arrDic = [NSMutableDictionary dictionary]; arrDic[NSForegroundColorAttributeName] = [UIColor purpleColor]; arrDic[NSBackgroundColorAttributeName] = [UIColor greenColor]; arrDic[NSKernAttributeName] = @10; arrDic[NSUnderlineStyleAttributeName] = @1; NSMutableAttributedString *attriOneStr = [[NSMutableAttributedString alloc]initWithString:@"来呀,快活呀,反正有大把时光" attributes:arrDic]; self.oneLabel.attributedText = attriOneStr; // 简单的图文混排 NSMutableAttributedString *arrTwoStr = [[NSMutableAttributedString alloc]init]; NSMutableAttributedString *TwoChildStr = [[NSMutableAttributedString alloc]initWithString:@"你好啊"]; [arrTwoStr appendAttributedString:TwoChildStr]; NSTextAttachment *attachMent = [[NSTextAttachment alloc]init]; attachMent.image = [UIImage imageNamed:@"2"]; attachMent.bounds = CGRectMake(0, -5, 20, 20); NSAttributedString *picStr = [NSAttributedString attributedStringWithAttachment:attachMent]; [arrTwoStr appendAttributedString:picStr]; NSAttributedString *TwooStr = [[NSAttributedString alloc]initWithString:@"我是小菜鸟"]; [arrTwoStr appendAttributedString:TwooStr]; self.twoLabel.attributedText = arrTwoStr;
相关文章推荐
- NSMutableAttributedString-富文本的使用
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、划线等等)
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)
- 富文本 ---- NSMutableAttributedString
- iOS NSMutableAttributedString 实现富文本
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)
- NSMutableAttributedString设置图片与文本的垂直位置
- NSMutableAttributedString实现富文本
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)
- NSMutableAttributedString实现富文本 (实现不同颜色和字体、下划线)
- iOS NSMutableAttributedString/NSAttributedString 富文本设置
- 使用NSMutableAttributedString 实现富文本
- iOS - NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)
- NSMutableAttributedString IOS中的富文本
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)
- iOS - NSMutableAttributedString 富文本的实现
- 富文本NSMutableAttributedString的相关设置
- iOS使用NSMutableAttributedString 实现富文本
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)