NSString *needText = @"冰河时代(37)";
[self.topLabel setAttributedText:[self changeLabelWithText:needText]];
//创建一个返回富文本的方法
-(NSMutableAttributedString) changeLabelWithText:(NSString)needText{
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:needText];
UIFont *font = [UIFont systemFontOfSize:20];
[attrString addAttribute:NSFontAttributeName value:font range:NSMakeRange(0,4)];
[attrString addAttribute:NSFontAttributeName value:[UIFont fontWithHiraKakuProNW3:12] range:NSMakeRange(4,needText.length-4)];
return attrString;
}
网友评论