UILable,UIButton的富文字顯示
阿新 • • 發佈:2019-01-08
//富文字
NSString *str = [NSStringstringWithFormat:@"答對%@次後自動移除錯題",@"3"];
NSMutableAttributedString *attr = [[NSMutableAttributedStringalloc]initWithString:str];
int a=0;
int b=0;
if ([str rangeOfString:@"次"].length) {
a = [strrangeOfString
}
if ([str rangeOfString:@"對"].length) {
b = [strrangeOfString:@"對"].location;
}
[attraddAttribute:NSForegroundColorAttributeNamevalue:[UIColorcolorWithHexString:@"0099cc"]range:NSMakeRange(b+1, a-1)];
SZLab