创建
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"喵了个咪的猫"];
改变大小 UIFont italicSystemFontOfSize:10 “3”代表从第几个字符开始 “2”代表是第几个字符开始改变几个字符 NSMakeRange(3, 2)
[attStr setAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} range:NSMakeRange(0, 3)];
[attStr setAttributes:@{NSFontAttributeName:[UIFont italicSystemFontOfSize:10]} range:NSMakeRange(3, 2)];
改变颜色
[attStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(5, 1)];
网友评论