//帶有屬性的文字
//1.創建對象
NSString *original = @"今天你還好嗎?";
NSMutableAttributedString *attrTitle = [[NSMutableAttributedStringalloc] initWithString:original];
//2.設置顏色(NSForegroundColorAttributeName代表要設置顏色, value代表值, range 代表范圍)
/**
其他設置:
1.NSForegroundColorAttributeName //顏色
2.NSFontAttributeName //字體
3.NSBackgroundColorAttributeName //背景色
//還有其他的很多的屬性,可以自己去看蘋果的API,這里不再詳述
*/
[attrTitle addAttribute:NSForegroundColorAttributeName value:[UIColorblueColor] range:NSMakeRange(0, 2)];
//3.添加到Label中
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(100, 100, 100, 40);
[label setAttributedText:attrTitle];
[self.view addSubview:label];