UILabel设置多种字体、颜色(文本中字体不同颜色)
2015-04-30 11:52
483 查看
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String,try your best to test attributed string text"]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:30.0] range:NSMakeRange(0, 5)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:30.0] range:NSMakeRange(6, 12)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:30.0] range:NSMakeRange(19, 6)]; UILabel *attrLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 150, 320 - 40, 90)]; attrLabel.attributedText = str; attrLabel.numberOfLines = 0; [self.view addSubview:attrLabel];
http://blog.csdn.net/woaifen3344/article/details/38352099
相关文章推荐
- UILabel设置多种字体、颜色
- iOS:UILabel设置不同字体颜色
- UILabel设置多种字体、颜色
- 给UIlabel设置不同字体 颜色 下划线
- SpannableStringBuilder为文本设置不同字体大小,颜色
- 给UILabel设置不同的字体和颜色
- [UILabel]设置不同颜色、字体
- [置顶] UILabel的text设置不同颜色、字体
- UILabel设置不同的字体颜色
- UILabel 设置不同颜色,不同字体
- UILabel设置多种字体、颜色 (NSMutableAttributedString)
- iOS设置改变UILabel、UIButton的多种颜色和字体大小(非常好用)
- 设置UILabel 字体不同字符不同颜色
- swift---不同字体大小不同颜色label富文本设置
- UILabel设置不同的字体不同的颜色
- iphone ios 如何在同一行中显示不同字体,颜色文本(UILabel)
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- textview设置多种不同的字体颜色和点击事件
- UILabel设置多种字体、颜色