UILabel显示多行文本,字体设置
来源:互联网 发布:中国农业银行软件下载 编辑:程序博客网 时间:2024/06/08 02:54
在一个UILabel中拼成几段文本,并且字体不同。
UILabel showLabel = [[UILabel alloc] init];
showLable.numberOfLines = 0; NSString *text = @"Manufacture: "; text = [text stringByAppendingString:response.manufacture]; text = [text stringByAppendingString:@"\nModelNo: "]; text = [text stringByAppendingString:response.modelNo]; text = [text stringByAppendingString:@"\nFirmwareVersion: "]; text = [text stringByAppendingString:response.firmwareVersion]; text = [text stringByAppendingString:@"\nproductId: "]; text = [text stringByAppendingString:response.productId]; text = [text stringByAppendingString:@"\nbatteryStatus: "]; text = [text stringByAppendingString:[NSString stringWithFormat:@"%d", response.batteryStatus]]; text = [text stringByAppendingString:@"\nbatteryPercent: "]; text = [text stringByAppendingString:[NSString stringWithFormat:@"%d", response.batteryPercent]]; text = [text stringByAppendingString:@"\nbatteryVoltage: "]; text = [text stringByAppendingString:[NSString stringWithFormat:@"%d", response.batteryVoltage]]; text = [text stringByAppendingString:@"\nbatteryTemperature: "]; text = [text stringByAppendingString:[NSString stringWithFormat:@"%d", response.batteryTemperature]]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:text]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,12)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:20.0] range:NSMakeRange(0, 12)]; showLable.attributedText = str;
结果:
0 0
- UILabel显示多行文本,字体设置
- Iphone UILabel显示多行文本
- AutoLayout下多行UILabel无法显示多行文本的问题
- iOS开发UILabel多行文本设置行间距
- UILabel 显示多行文字
- 「Swift学习笔记」使用UILabel显示多行文本
- SetDlgItemText显示多行文本
- 多行文本显示省略号
- UILabel 多行文本及动态计算其高度
- IOS计算UILabel单行高度、计算UILabel多行文本高度、宽度的技巧,根据文本的高度设置cell高度
- svg中显示多行文本
- TextOut显示多行文本的方法
- TextBox显示多行文本/Environment.NewLine
- svg中显示多行文本
- 多行文本溢出显示省略号...
- 多行文本溢出显示省略号…
- WebKit多行文本溢出显示省略号(...)
- 多行文本溢出显示省略号
- appium源码分析(十三)-UpdateStrings
- Spring中事务与aop的先后顺序问题
- APP 接口保护文档
- VS2010环境下用c++语言在MFC对话框程序中连接及操作Mysql 数据库
- HibernateTemplate和HibernateDaoSupport
- UILabel显示多行文本,字体设置
- C# Mutex对象的使用
- Eclipse 中 Ant 无日志输出
- 关于《算法的乐趣》傅立叶变换一章的补充
- 剖析Android中进程与线程调度之nice
- SpannableString、SpannableStringBuilder与String的关系
- 任何时间,都可以开始
- 队列的两种实现:数组和链表
- IOS 本地保存Crash日志信息