文字列のスタイルを変更するには、
- デフォルトのスタイルのコピーを取って、
- そのプロパティを変更し、
- 適用する。
title = "title"
//ダメ let style = NSMutableParagraphStyle.defaultParagraphStyle()
let textStyle = NSParagraphStyle.defaultParagraphStyle().mutableCopy() as! NSMutableParagraphStyle
textStyle.alignment = NSTextAlignment.Center
let textFontAttributes = [
NSParagraphStyleAttributeName: textStyle
]
let textRect = CGRectMake(0, 0, 20, 10)
title.drawInRect(textRect, withAttributes: textFontAttributes)
ブログやっています:http://weed.nagoya