iOS Dev (4) 用TTTAttributedLabel创建变化丰富的UILabel
2013-08-16 11:18
381 查看
iOS Dev (4) 用TTTAttributedLabel创建变化丰富的UILabel
2013年8月16日1. 不同颜色的字段混合在一个Label里怎么实现?
看TTTAttributedLabel是怎么做的:
TTTAttributedLabel *hintLabel1 = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(10.0, 10.0, 300, 30.0)]; [hintLabel1 setNumberOfLines:2]; [hintLabel1 setFont:[UIFont systemFontOfSize:12.0f]]; [hintLabel1 setBackgroundColor:[UIColor clearColor]]; [hintLabel1 setTextAlignment:NSTextAlignmentLeft]; [hintLabel1 setLineBreakMode:NSLineBreakByWordWrapping]; NSMutableAttributedString *hintString1 = [[NSMutableAttributedString alloc] initWithString:@"今天是个好日子。"]; [hintString1 addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[[UIColor blueColor] CGColor] range:NSMakeRange(3,3)]; [hintLabel1 setText:hintString1]; [self.view addSubview:hintLabel1];
2. 其他用法
自己探索吧。Ref: https://github.com/mattt/TTTAttributedLabel
相关文章推荐
- 用TTTAttributedLabel创建变化丰富的UILabel
- 富文本(TTTAttributedLabel是一个替代,UILabel提供了一种简单的方式来高效地呈现属性字符串。作为奖励,它还支持链接嵌入,自动与NSTextCheckingTypes手动通过指定)
- iOS TTTAttributedLabel 使用
- iOS之UILabel------分类创建label,计算文本大小
- iOS 实现数字动态变化的 UILabel:EFCountingLabel
- iOS学笔记本45- TTTAttributedLabel 使用方法
- iOS TTTAttributedLabel复制
- TYAttributedLabel——简单,强大的iOS属性文本控件
- iOS UILabel的高度随着字数的多少变化而变化
- iOS_数字变化(UICountingLabel与CADisplayLink)
- 富文本点击事件-TTTAttributedLabel和YYtext的不同用法
- TTTAttributedLabel
- 【iOS】Illegal Configuration: The Label outlet from the ViewController to the UILabel is invalid. Outl
- iOS-UIKit(UILabel.h常用技巧1(随字体多行后的高度,渐变字体Label,自适应高度,添加边框))
- ios 设置label的高度随着内容的变化而变化
- TTTAttributedLabel
- TTTAttributedLabel 使用方法
- iOS - UILabel 的一些属性设置(间距、删除线等、计算文本label的size等)
- iOS学习笔记 4 —— 代码创建界面UIView、UILabel、UITextField、UIButton
- TTTAttributedLabel 使用方法 (可点击文字文本)