2015-10-05 56 views
1

導入我的字體在我的項目我fontSize的不符合我的自定義字體工作

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) 

} 

在我的視圖控制器,我打電話我的標籤中的字體GothamMedium:

myLabel.font=Style.GothamMedium 

字體是否正確但字體大小不起作用。 你能告訴我如何改變字體大小嗎?

+0

不工作怎麼樣?標籤上有什麼設置?您是否在運行時調試過檢查標籤設置? – Wain

回答

5

font namefont file name之間有區別,您提到了font file name而不是font name。雙擊字體,它會在Font Book打開,標題是font name現在font應創建爲

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

Font Name

plist另外補充Fonts provided by application。看到這個link

+0

謝謝!!!它正在工作! – Malicia