ios - 我的字体大小不适用于我的自定义字体

标签 ios swift fonts font-size uifont

我在我的项目中导入我的字体

enter image description here

我创建了一个类 style.swift

struct Style {


    //fonts
    static var GothamBlackItalic = UIFont(name: "Gotham-BlackItalic.ttf", size: 12)
    static var GothamBold = UIFont(name: "Gotham-Bold.ttf", size: 12)
    static var GothamBoldItalic = UIFont(name: "Gotham-BoldItalic.ttf", size: 12)
    static var GothamBook = UIFont(name: "Gotham-Book.ttf", size: 12)
    static var GothamBookItalic = UIFont(name: "Gotham-BookItalic.ttf", size: 12)
    static var GothamLight = UIFont(name: "Gotham-Light.ttf", size: 12)
    static var GothamLightItalic = UIFont(name: "Gotham-LightItalic.ttf", size: 12)
    static var GothamMedium = UIFont(name: "Gotham-Medium.ttf", size: 4)
    static var GothamMediumItalic = UIFont(name: "Gotham-MediumItalic.ttf", size: 12)
    static var GothamThin = UIFont(name: "Gotham-Thin.ttf", size: 12)
    static var GothamThinItalic = UIFont(name: "Gotham-ThinItalic.ttf", size: 12)
    static var GothamUltra = UIFont(name: "Gotham-Ultra.ttf", size: 12)
    static var GothamUltraItalic = UIFont(name: "Gotham-UltraItalic.ttf", size: 12)
    static var GothamExtraLight = UIFont(name: "Gotham-XLight.ttf", size: 12)
    static var GothamExtraLightItalic = UIFont(name: "Gotham-XLightItalic.ttf", size: 12)

}

在我的 View Controller 中,我在标签中调用字体 GothamMedium :

myLabel.font=Style.GothamMedium

字体正确但字体大小不正常。 你能告诉我如何更改字体大小吗?

最佳答案

字体名字体文件名是有区别的,你说的是字体文件名,不是字体名。双击字体,它会在Font Book中打开,标题是字体名称,现在font应该被创建为

static var GothamBlackItalic = UIFont(name: "Gotham Black", size: 12)

Font Name

同时在您的plist 中添加Fonts provided by application。看这个link

关于ios - 我的字体大小不适用于我的自定义字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32946911/

相关文章:

encoding - sarcmark是如何实现的?

python - 为已安装的字体创建标签名称并以字体样式显示字体名称

java - 为什么 java 1.7 中的字体与 1.6 中的字体不同?

ios - 在 AVPlayer 中播放视频

ios - 如何 Hook subview 的 subview ?

ios - 从动态数组的部分中的标题中返回标题

Xcode:如何退出lldb swift repl

ios - 带有加载事件指示器的 UITableView 子类

ios - 了解CAGradient的位置?

swift - 如何使用 SwiftUI 获取鼠标位置?