1. 程式人生 > >UILable,UIButton的富文字顯示

UILable,UIButton的富文字顯示

//富文字

           NSString *str = [NSStringstringWithFormat:@"答對%@次後自動移除錯題",@"3"];

NSMutableAttributedString *attr = [[NSMutableAttributedStringalloc]initWithString:str];

           int a=0;

           int b=0;

           if ([str rangeOfString:@""].length) {

                a = [strrangeOfString

:@""].location;

            }

           if ([str rangeOfString:@""].length) {

                b = [strrangeOfString:@""].location;

            }

            [attraddAttribute:NSForegroundColorAttributeNamevalue:[UIColorcolorWithHexString:@"0099cc"]range:NSMakeRange(b+1, a-1)];

           SZLab

.attributedText = attr;