MotionInMotion Episode 24 - Formatting Rich Text With NSAttributedString
Formatting Rich Text With NSAttributedString - MotionInMotion
いろいろなスタイルの文字を表示
- NSAttributedString
- NSMutableAttributedString
- NSFontAttributeName
- UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
- NSParagraphStyleAttributeName
- NSMutableParagraphStyle.new.tap do |ps|
- ps.lineHeightMultiple = 1.5
- NSMutableParagraphStyle.new.tap do |ps|
- NSForegroundColorAttributeName
- NSBackgroundColorAttributeName
- NSKernAttributeName
- 文字間の幅
- NSStrikethroughStyleAttributeName
- NSUnderlineStyleSingle
- NSStrokeColorAttributeName
- NSStrokeWidthAttributeName
- 正の値のときは縁取りの内側はclearColor
- 負の値のときは内側がNSForegroundColorAttributeName
- NSShadowAttributeName
- NSShadow.new.tap do |shadow|
- shadow.shadowOffset = [3, 3]
- shadow.shadowBlurRadius = 3
- shadow.shadowColor = UIColor.redColor
- NSShadow.new.tap do |shadow|
- @font_label.attributedText = NSAttributedString.alloc.initWithString
- multi text (NSMutableAttributedString)
- multi_text = NSMutableAttributedString.alloc.initWithString
- multi_text.addAttributes
- @multi_label.attributedText = multi_text