UILabel设置多种字体、颜色
2014-08-02 21:57
218 查看
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String,try your best to test attributed string text"]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:30.0] range:NSMakeRange(0, 5)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:30.0] range:NSMakeRange(6, 12)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:30.0] range:NSMakeRange(19, 6)]; UILabel *attrLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 150, 320 - 40, 90)]; attrLabel.attributedText = str; attrLabel.numberOfLines = 0; [self.view addSubview:attrLabel];
相关文章推荐
- UILabel设置多种字体、颜色(文本中字体不同颜色)
- UILabel设置多种字体、颜色 (NSMutableAttributedString)
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- iOS设置改变UILabel、UIButton的多种颜色和字体大小(非常好用)
- UILabel设置多种字体、颜色
- android TextView的字体颜色设置的多种方法
- TextView的字体颜色设置的多种方法
- UILabel 设置不同颜色,不同字体
- android TextView的字体颜色设置的多种方法
- IOS中一段文字设置多种字体颜色代码
- UILabel设置不同的字体不同的颜色
- android 设置字体颜色、EditText自己主动输入转换成大写字母的多种方式
- UILabel设置不同的字体颜色
- iOS:UILabel设置不同字体颜色
- android 设置字体颜色、EditText自动输入转换成大写字母的多种方式
- uilabel 的相关处理 类富文本(自动换行,设置行高,同一个label多种颜色,给文字加下划线 首行缩进 等 等)
- 设置UILabel 字体不同字符不同颜色
- ios设置UILabel中文字的不同颜色和字体字号