用NSAttributedString画下划线
2015-07-09 12:29
399 查看
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)]; [self.view addSubview:lable]; lable.backgroundColor = [UIColor redColor]; lable.textAlignment = NSTextAlignmentCenter; NSString *oldPrice = @"¥ 999999"; NSUInteger length = [oldPrice length]; [self.view addSubview:lable]; NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice]; [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)]; [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(0, length)]; [lable setAttributedText:attri];
相关文章推荐
- CSS小例子(只显示下划线的文本框,像文字一样的按钮)
- 用CSS实现链接的虚线下划线效果
- php把大写命名转换成下划线分割命名
- android TextView加下划线的方法
- Python中的下划线详解
- Python中下划线的使用方法
- zabbix学习(十)Item Key相关
- 3. 标示符
- 什么是BNF范式,什么又是EBNF范式
- php基础教程:变量
- Python 用下划线作为变量前缀和后缀指定特殊变量
- TextView下划线
- TextView使用超链接去掉下划线
- Android HTML标签 换行 加粗
- edit控件小技巧(mark)
- TextView 设置无下划线超链接
- 一篇解答xstream转换过程中可能出现问题的作文
- sql like语句中的通配符:百分号、下划线和escape
- python中下划线,双下划线,首尾双下划线的区别(Difference between _, __ and __xx__ in Python)
- Python中的下划线