परिभाषित करें और निर्यात (फ़ाइलों में या precompi में एक शीर्षलेख शामिल करके नेतृत्व हेडर) UIFont
के एक वर्ग के रूप में निम्नलिखित:
@implementation UIFont (Utils)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
+ (UIFont *)systemFontOfSize:(CGFloat)size
{
return [UIFont fontWithName:@"YOUR_TRUETYPE_FONT_NAME_HERE" size:size];
}
+ (UIFont *)lightSystemFontOfSize:(CGFloat)size
{
return [UIFont fontWithName:@"YOUR_TRUETYPE_FONT_NAME_HERE" size:size];
}
+ (UIFont *)boldSystemFontOfSize:(CGFloat)size
{
return [UIFont fontWithName:@"YOUR_TRUETYPE_FONT_NAME_HERE" size:size];
}
+ (UIFont *)preferredFontForTextStyle:(NSString *)style
{
if ([style isEqualToString:UIFontTextStyleBody])
return [UIFont systemFontOfSize:17];
if ([style isEqualToString:UIFontTextStyleHeadline])
return [UIFont boldSystemFontOfSize:17];
if ([style isEqualToString:UIFontTextStyleSubheadline])
return [UIFont systemFontOfSize:15];
if ([style isEqualToString:UIFontTextStyleFootnote])
return [UIFont systemFontOfSize:13];
if ([style isEqualToString:UIFontTextStyleCaption1])
return [UIFont systemFontOfSize:12];
if ([style isEqualToString:UIFontTextStyleCaption2])
return [UIFont systemFontOfSize:11];
return [UIFont systemFontOfSize:17];
}
#pragma clang diagnostic pop
@end
लाइट संस्करण आईओएस 7 का आनंद लें के साथ शुरू एक उपयोगी अतिरिक्त के रूप में आता है! ;)
क्या आपने यूफॉन्ट के लिए श्रेणी बनाने का प्रयास किया था? – NeverBe
क्या आप निश्चित हैं * आप इसे बदलना चाहते हैं? इस प्रकार झटकेदार इंटरफेस पैदा होते हैं। – Dave
@ डेव: हां। मुझे यकीन है कि मैं इसे बदलना चाहता हूं :) –