NSMutableAttributedString
来源:互联网 发布:最准确的生男生女算法 编辑:程序博客网 时间:2024/03/28 23:58
带属性的字符串(NSMutableAttributedString)的使用
//带有属性的文字
//1.创建对象
NSString *original = @"今天你还好吗?";
NSMutableAttributedString *attrTitle = [[NSMutableAttributedStringalloc] initWithString:original];
//2.设置颜色(NSForegroundColorAttributeName代表要设置颜色, value代表值, range 代表范围)
/**
其他设置:
1.NSForegroundColorAttributeName //颜色
2.NSFontAttributeName //字体
3.NSBackgroundColorAttributeName //背景色
//还有其他的很多的属性,可以自己去看苹果的API,这里不再详述
*/
[attrTitle addAttribute:NSForegroundColorAttributeName value:[UIColorblueColor] range:NSMakeRange(0, 2)];
//3.添加到Label中
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(100, 100, 100, 40);
[label setAttributedText:attrTitle];
[self.view addSubview:label];
资源来自于:http://www.cnblogs.com/d2688/p/3622344.html
0 0
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString 使用
- NSMutableAttributedString使用
- NSMutableAttributedString 文字处理 。。。
- NSMutableAttributedString使用
- NSMutableAttributedString初探
- NSMutableAttributedString mode
- 类型检查
- Struts2 拦截器处理普通Http请求和Ajax请求时拦截配置
- storm部署安装deploy
- 内置函数
- JSP页面跳转的五种方法
- NSMutableAttributedString
- 多线程处理for循环
- 限制在同一台电脑上只允许有一个用户登录系统
- Android activity 之间的数据传递 bundle
- java 子类重写父类的方法应注意的问题
- ssh项目中启动tomcat报错:session not found
- C#创建windows服务
- IOS推送详解
- POI读取Excel(兼容Excel2003、Excel2007)