NSMutableAttributedString
来源:互联网 发布:天敏智能网络机顶盒价格 编辑:程序博客网 时间:2024/05/11 11:05
//button设置下划线
NSMutableAttributedString *str =[[NSMutableAttributedString alloc] initWithString:@"月利宝产品详情"];
[str addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:(NSRange){0,[str length]}]; //下划线样式
[str addAttribute:NSUnderlineColorAttributeName value:[UIColor redColor] range:(NSRange){0,[str length]}]; //下划线颜色
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:(NSRange){0,[str length]}]; //字体颜色
[self.detailBtn setAttributedTitle:str forState:(UIControlStateNormal)];
// 效果
// 一段文字显示不同的颜色和字体
UILabel *testLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 320, 30)]; testLabel.backgroundColor = [UIColor lightGrayColor]; testLabel.textAlignment = NSTextAlignmentCenter; NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"今天天气不错呀"]; [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0] range:NSMakeRange(2, 2)]; [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(2, 2)]; testLabel.attributedText = AttributedStr; [self.view addSubview:testLabel];
// 效果 0 0
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString
- NSMutableAttributedString 使用
- NSMutableAttributedString使用
- NSMutableAttributedString 文字处理 。。。
- NSMutableAttributedString使用
- NSMutableAttributedString初探
- NSMutableAttributedString mode
- AndroidN编译错误
- LCT函数详解
- hdu2056 Rectangles
- 系统安装
- 你真的会沟通吗? --下部
- NSMutableAttributedString
- Laravel研究笔记二(artisan命令列表)
- kafka单机版环境搭建与测试
- @Override 注解报错,eclipse
- .NET(C#)连接各类数据库
- android:versionCode和android:versionName 用途
- 杨辉三角形-C描述
- 浅谈Java中的equals和==
- bzoj2565(manacher)