2015-11-30 35 views
7

Etiket metni Sistem İnce olarak ayarlamak istiyorum. StackOverflow'ta oku ve şu şekilde bir cevap buldu:Swift'de System Thin olarak metin yazı tipi nasıl ayarlanır?

labelDescriptionView.font = UIFont(name: "System-Thin", size: 15.0) 

ama işe yaramadı. Kodumu nasıl geliştirebilirim ve İnce yazı tipi stilini programlı olarak nasıl yapabilirim?

+0

Bunu nereden buldunuz? –

+0

@MartinR http://stackoverflow.com/questions/22091367/how-to-set-font-name-of-uilabel-as-helveticaneue-thin-in-ios –

+0

@MartinR oh, yanlış cevap verdim =/ –

cevap

22

Arabirim Oluşturucu'daki system yazı tipi, varsayılan işletim sistemi yazı tipidir, adının alabileceği bir yazı tipi değildir.

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize; 
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 

Bunlar herhangi ince bir sürümünü içermez ama iso 8.2 kullanabilirsiniz edebilirsiniz:

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize weight:(CGFloat)weight; 

geçmek yerler: ağırlık olarak:

sistem yazı için Apple şu yöntemleri sağlar
UIFontWeightUltraLight 
UIFontWeightThin 
UIFontWeightLight 
UIFontWeightRegular 
UIFontWeightMedium 
UIFontWeightSemibold 
UIFontWeightBold 
UIFontWeightHeavy 

Yani ince bir sistem yazı olacaktır:

UIFont *thinFont = [UIFont systemFontOfSize:15 weight:UIFontWeightThin]; 
12

iOS 8.2 veya daha üst bir sürümünü kullanıyorsanız bunu kullanabilirsiniz;

label.font = UIFont.systemFontOfSize(15, weight: UIFontWeightThin) 

Önceki sürümlerde yazı tipiniz olarak sadece HelveticaNeue-Thin kullanın.