ios-Label中显示多种样式的字体
来源:互联网 发布:制作精品课程网站软件 编辑:程序博客网 时间:2024/04/28 13:36
#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; /** * 如何让一个Label上显示两种颜色 或者两种不同颜色的字体 我们可以用两种方式实现 1.使用CoreText 这种方式偏向 底层 实现起来较为复杂 2.使用属性字符串 * * @return <#return value description#> */ [self show]; // Do any additional setup after loading the view, typically from a nib.}- (void)show{ /** * 属性字符串 * * @return <#return value description#> */ NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc]initWithString: @"Can you see me ?"]; /** * 指定范围添加属性 * * @return <#return value description#> */ [attributeString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:40],NSForegroundColorAttributeName:[UIColor redColor]} range:NSMakeRange(0, 1)]; [attributeString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor lightGrayColor]} range:NSMakeRange(1, 5)]; [attributeString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25],NSForegroundColorAttributeName:[UIColor greenColor]} range:NSMakeRange(5, 10)]; UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, 200, 50)]; label.attributedText = attributeString; [self.view addSubview:label]; }- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- ios-Label中显示多种样式的字体
- NSMutableAttributedString同一个label中显示不同的字体样式
- iOS中关于设置label字体样式
- iOS在一个label中显示不同颜色的字体
- iOS - 同一个Label的不同样式显示
- label中不同颜色字体的显示
- Navigation Bar的title 多种字体 label
- iOS 关于label上显示不同颜色的字体
- IOS小技巧——如何润色一个Label, 一个label中,展现多种字体效果(图文混编 1)
- label中显示不同颜色的字以及不同字体,字体高亮,DIY label
- label中显示不同颜色的字以及不同字体,字体高亮,DIY label
- iOS项目开发实战——Label中字体字号与Label多行显示
- label显示不同颜色的字体
- label 中可以显示不同字体,不同颜色 的text
- 一个Label中显示不同的字体颜色
- iOS Label 设置多种字体、颜色,支持换行符
- iOS Label显示不同颜色和字体
- iOS同一个label中设置不同的字体及颜色
- 内存各个区域的区别
- Feedforward Deep Networks(要点)
- java中wait/notify机制
- CentOs7修改密码
- python核心编程 习题7-10
- ios-Label中显示多种样式的字体
- Scala---文件读取、写入、控制台操作
- abstract class和interface的区别
- 利用WMI打造完美三无后门(scrcons.exe)
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>意义
- caffe训练网络的实践
- Deep learning系列(十)随机梯度下降
- ORACLE异常总结
- fstream 打开文件失败,读取文件内容为空