正確設置CATextLayer的Font

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;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章