UILabel的使用
1、创建并设置位置尺寸
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 40, 120, 44)];
[self.view addSubview:myLabel];
2、设置文字
NSString *text = @"标签文本";
myLabel.text = text;
3、设置文字颜色
myLabel.textColor = [UIColor blueColor];
4、设置标签文本
NSString *text = @"其实没什么";
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:text];
[attributeString setAttributes:@{
NSForegroundColorAttributeName : [UIColor redColor],
NSFontAttributeName : [UIFont systemFontOfSize:17]
} range:NSMakeRange(2, 1)];
myLabel.attributedText = attributeString;