Swift 修改字体样式
作者:
_冷忆 | 来源:发表于
2018-08-09 15:23 被阅读25次extension UIFont {
// 可以通过let names = UIFont.fontNames(forFamilyName: "PingFang SC") 来遍历所有PingFang 的字体名字 iOS9.0 以后支持
/*
PingFangSC-Medium
PingFangSC-Semibold
PingFangSC-Light
PingFangSC-Ultralight
PingFangSC-Regular
PingFangSC-Thin
*/
public static func pingFangRegular(size: CGFloat) -> UIFont {
guard let font = UIFont(name: "PingFangSC-Regular", size: size) else {
return UIFont.systemFont(ofSize: size)
}
return font
}
public static func pingFangMedium(size: CGFloat) -> UIFont {
guard let font = UIFont(name: "PingFangSC-Medium", size: size) else {
return UIFont.systemFont(ofSize: size)
}
return font
}
public static func pingFangSemibold(size: CGFloat) -> UIFont {
guard let font = UIFont(name: "PingFangSC-Semibold", size: size) else {
return UIFont.systemFont(ofSize: size)
}
return font
}
}
本文标题:Swift 修改字体样式
本文链接:https://www.haomeiwen.com/subject/dxqcbftx.html
网友评论