NSAttributedString的NSUnderlineStyleSingle在iOS8.1上无效的解决方法
2015-08-03 14:44
507 查看
英文好的直接上原文:http://stackoverflow.com/questions/26136157/underline-part-of-a-string-using-nsmutableattributedstring-in-ios8-is-not-workin
问题:在iOS8.1上(8.4不存在,估计苹果已修复),NSMutableAttributedString(NSAttributedString也一样),如果有2段string,第二段使用删除线效果(NSUnderlineStyleSingle)会无效。
解决方法:第一段string设置NSStrikethroughStyleAttributeName为NSUnderlineStyleSingle
问题:在iOS8.1上(8.4不存在,估计苹果已修复),NSMutableAttributedString(NSAttributedString也一样),如果有2段string,第二段使用删除线效果(NSUnderlineStyleSingle)会无效。
解决方法:第一段string设置NSStrikethroughStyleAttributeName为NSUnderlineStyleSingle
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"test " attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)}]]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"s" attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSBackgroundColorAttributeName: [UIColor clearColor]}]]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"tring"]];
相关文章推荐
- IOS 开发xcode 6.3以后 自制FrameWork教程
- iOS开发中tableview中cell图片自定义方法。
- IOS中几种数据持久化方案,我要永远记住你!
- ios自动布局
- 【IOS】仿QQ侧滑菜单
- iOS高级-QuartzCore框架-CoreAnimation
- IOS第六天(3:scrollView 图片轮播器)
- iOS开发——加载、滑动翻阅大量图片解决方案详解
- IOS第六天(2:10秒倒计时)
- 关于iOS多线程,你看我就够了(已更新)
- IOS第六天(1:scrollView 属性和查看大图)
- iOS——开发周报(2015-07-31)
- iOS中几种数据持久化方案
- 使用Xcode和Instruments调试解决iOS内存泄露
- iOS 7 导航 路线
- IOS中得block代码块的定义及使用
- iOS关于关于动态函数的操作
- 【iOS地图导航】“步行导航”及“HUD导航”的实现,demo+高清源码,大家按需自取~~
- 最近了解了一下ios开发的相关资料,把开源的相关文章进行记录
- iOS实现渐变背景色的三种方法