给 UILabel 中的文字增加 line-through / Strikethrough (删除线)样式

iOS 6 中苹果引入了 NSStrikethroughStyleAttributeName 属性,用于设置 NSAttributedString 的删除线样式,用法如下:

let attributedText = NSAttributedString(string: "内容", attributes: [NSStrikethroughStyleAttributeName: 1])
let contentLabel = UILabel()
contentLabel.attributedText = attributedText

其中:

[NSStrikethroughStyleAttributeName: 1]

0 表示不显示删除线,1 表示显示删除线。

 
 
 
 
posted @ 2015-07-23 11:28  Cheetah_yang  阅读(386)  评论(0编辑  收藏  举报