iOS中,通常設置字體都是使用UIFont, 但是CATextLayer例外,詳細閱讀CATextLayer Class Reference,
May be either a CTFontRef
, a
CGFontRef
, an instance of
NSFont
(Mac OS X only), or a string naming the font. In iOS, you cannot assign a
UIFont
object to this property. Defaults to Helvetica.
The font
property is only used when the string
property is not an NSAttributedString
.
Note: If the font property is a CTFontRef
, a
CGFontRef
, or an instance of NSFont
, the font size of the property is ignored.
設置CATextLayer字體:
錯誤: textLayer.font = [UIFont fontWithName:@"HiraKakuProN-W3" size:12];正確: textLayer.font = @"HiraKakuProN-W3"; textLayer.fontSize = 12;