我正在尝试将UILabel中的字体设置为自定义字体,但也使其变为粗体而没有成功。到目前为止,我的努力如下:
自定义字体:
cell.folderName.font = UIFont.init(name: "American Typewriter", size: 20)
如何使上述字体也加粗/或斜体?
答案 0 :(得分:1)
此枚举可用于AmericanTypewriter类型。
public enum americanTypewriter: String {
case typewriter = "AmericanTypewriter"
case bold = "AmericanTypewriter-Bold"
case condensed = "AmericanTypewriter-Condensed"
case condensedBold = "AmericanTypewriter-CondensedBold"
case condensedLight = "AmericanTypewriter-CondensedLight"
case light = "AmericanTypewriter-Light"
public func font(size: CGFloat) -> UIFont {
return UIFont(name: self.rawValue, size: size)!
}
}
大胆
cell.folderName.font = UIFont.init(name: "AmericanTypewriter-Bold", size: 20)
答案 1 :(得分:0)
字体美国打字机没有斜体样式。但它具有粗体样式。
因此,如果您需要设置粗体字体,只需使用
"AmericanTypewriter-Bold"
所有 American Typewriter 字体样式:
AmericanTypewriter-CondensedBold
AmericanTypewriter-Condensed
AmericanTypewriter-CondensedLight
AmericanTypewriter
AmericanTypewriter-Bold
AmericanTypewriter-Semibold
AmericanTypewriter-Light