IOS UILabel 中 颜色混排

2016-05-27  本文已影响61人  JoeWcc

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];

上一篇下一篇

猜你喜欢

热点阅读