NSMutableAttributedString 富文本框 设置下划线
2015-09-20 12:36
357 查看
NSString *priceString = [NSString
stringWithFormat:@"原价:%@万", myModel.price];
NSMutableAttributedString *attributedString1 = [self
setLabelAttriButeString:priceString
andModelLength:myModel.price2.length];
[attributedString1 addAttribute:NSStrikethroughStyleAttributeName
value:[NSNumber
numberWithInteger:NSUnderlinePatternSolid |
NSUnderlineStyleSingle] range:NSMakeRange(0, priceString.length)];
- (NSMutableAttributedString *)setLabelAttriButeString:(NSString *)text andModelLength:(NSInteger)modelLength
{
NSMutableAttributedString *attributedString = [[NSMutableAttributedString
alloc] initWithString:text];
[attributedString addAttribute:NSForegroundColorAttributeName
value:[UIColor
orangeColor] range:NSMakeRange(3, modelLength)];
return attributedString;
}
stringWithFormat:@"原价:%@万", myModel.price];
NSMutableAttributedString *attributedString1 = [self
setLabelAttriButeString:priceString
andModelLength:myModel.price2.length];
[attributedString1 addAttribute:NSStrikethroughStyleAttributeName
value:[NSNumber
numberWithInteger:NSUnderlinePatternSolid |
NSUnderlineStyleSingle] range:NSMakeRange(0, priceString.length)];
- (NSMutableAttributedString *)setLabelAttriButeString:(NSString *)text andModelLength:(NSInteger)modelLength
{
NSMutableAttributedString *attributedString = [[NSMutableAttributedString
alloc] initWithString:text];
[attributedString addAttribute:NSForegroundColorAttributeName
value:[UIColor
orangeColor] range:NSMakeRange(3, modelLength)];
return attributedString;
}
相关文章推荐
- CodeVS1280 无限序列
- oracle常用函数及示例
- 大龄屌丝自学笔记--Java零基础到菜鸟--020
- httpd-2.2相关知识总结
- 第三周项目4 顺序表应用(1)
- 中文宾州树库标记含义
- Unity UGUI鼠标穿透UI问题(Unity官方的解决方法)
- Android 属性动画(二):ObjectAnimator与ValueAnimator
- c++中的时间戳
- 逻辑与’&&’和逻辑或’||’的陷阱
- 猴子吃桃两种方法
- J2SE小结
- Activiti入门教程五(详解ProcessEngine的创建)
- Mybatis使用Redis二级缓存
- C中的+0与-0
- 用position:relative和float实现不定宽块级元素的居中
- 分析灰盒测试优点和缺点
- 第三周项目1 顺序表的基本运算(3)
- ROS探索总结(十七)——构建完整的机器人应用系统
- 怎样取整