美文网首页
iOS设置一个Label中,数字大小区别于文字

iOS设置一个Label中,数字大小区别于文字

作者: BabyNeedCare | 来源:发表于2018-11-12 09:15 被阅读0次

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;

}

相关文章

网友评论

      本文标题:iOS设置一个Label中,数字大小区别于文字

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