陈斌彬的技术博客

Stay foolish,stay hungry

Uilabel指定位置改变字体颜色

UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 60, 250, 30)];
[self.view addSubview:myLabel];
//这是我们的测试用的文本字符串数据
NSString *content = @"abc123a1b2c3你懂得888";
NSMutableAttributedString *attributeString  = [[NSMutableAttributedString alloc]initWithString:content];
[attributeString setAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor],NSFontAttributeName:[UIFont systemFontOfSize:25]} range:NSMakeRange(0, 10)];
myLabel.attributedText = attributeString;

Resource Reference