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;