需要在以下函数中传递
CGFont
。CGFontCreateCopyWithVariations(<#font: CGFont!#>, <#variations: CFDictionary!#>))
CGFont
。CGFontCreateCopyWithVariations(<#font: CGFont!#>, <#variations: CFDictionary!#>))
这里是一个小例子:
var font = UIFont.systemFontOfSize(15.0)
var fontName = font.fontName as NSString
var cgFont = CGFontCreateWithFontName(fontName);
var copiedFont = CGFontCreateCopyWithVariations(cgFont, nil)
UIFont
转换为可用的CGFont
:if let uiFont = UIFont(name: "Helvetica-Bold", size: 36.0),
let cgFont = CGFont(uiFont.fontName as CFString) {
// Do stuff
}
setFontSize(_ size: CGFloat)
。 - B Roy Dawson