美文网首页
IOS UILabel 中 颜色混排

IOS UILabel 中 颜色混排

作者: JoeWcc | 来源:发表于2016-05-27 12:49 被阅读61次

UILabel* colorLabel = [[UILabelalloc]init];

colorLabel.frame=CGRectMake(0,100,200,100);

colorLabel.textColor= [UIColorblackColor];

NSMutableAttributedString*colorStr = [[NSMutableAttributedStringalloc]initWithString:@"在哪里呀蛤蛤蛤拉风的"];

NSRangeredRange = [[colorStrstring]rangeOfString:@"哪里呀"];

[colorStraddAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor]range:redRange];

[colorLabelsetAttributedText:colorStr];

[colorLabelsizeToFit];

相关文章

网友评论

      本文标题:IOS UILabel 中 颜色混排

      本文链接:https://www.haomeiwen.com/subject/exxfdttx.html