When I use UILabel
, I set the system font as:
label.font = UIFont.systemFontOfSize(18, weight: UIFontWeightMedium)
Now I try to use CATextLayer
and I searched online and found out that the system font for iOS 9 is San Francisco
and the font name is .SFUIText-Medium
, so I try to set the font name as:
textLayer = CATextLayer()
textLayer.font = CTFontCreateWithName(".SFUIText-Medium", 18, nil)
However, the fonts shown on the device screen are not the same for UILabel
& CATextLayer
as explained above. What is the correct font name to be used in CATextLayer
here so that I can have exactly the same font displayed as the UILabel
?
Since iOS 7.0,
UIFont
andCTFont
have been “toll-free-bridged”. This means that you can treat aUIFont
asCTFont
, and vice versa. Thus:Result: