指定されたテキストの色やサイズを変更Lable

UILabel * countentLable = [[UILabel ALLOC] initWithFrame:CGRectMake(100、100、100、20)]。

countentLable.font = [UIFont systemFontOfSize:10]。

NSStringの* CommentStr = @ "10ハウスリプライ(23)"。

NSMutableAttributedString * attributeStr = [[NSMutableAttributedStringalloc] initWithString:CommentStr];

NSRange colorFondRange = NSMakeRange([[contentStr列] rangeOfString:@ "(23条)"]場所、[attributeStr列] rangeOfString @ "(23条)"]の長さ。)

// [CommentStr addAttribute:NSForegroundColorAttributeName値:[UIColor redColor]範囲:colorFondRange];あなただけのこのとの色を変更した場合

// [CommentStr addAttribute:NSFontAttributeName値:[UIFont systemFontOfSize:25]範囲:colorFondRange];あなただけの大きさを変更するために、これを使用する場合

[countentLable setAttributedText:CommentStr]。

[self.viewのaddSubview:countentLable]。

おすすめ

転載: www.cnblogs.com/FZP5/p/12497911.html