LoginSignup
3
7

More than 5 years have passed since last update.

[iOS] NSAttributedStringKeyを利用して取り消し線を引く

Posted at

概要

UITextLabel上に表示する文字列に、取り消し線(Strike through)を引きたい場合、下記のようにNSAttributedStringKeyを利用することで簡単に実装することができます。

let attributeString: NSMutableAttributedString =  NSMutableAttributedString(string: "Hello, World!!")
attributeString.addAttribute(NSAttributedStringKey.strikethroughStyle, value: 2, range: NSMakeRange(0, attributeString.length))

self.textLabel.attributedText = attributeString
3
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
7