UI常用字体定义和继承的实例,ResearchKitCode

本文介绍了一个针对 iOS 开发中 UIFont 类的自定义类别(Category),通过该类别可以方便地创建不同风格和尺寸的文字对象,适用于导航栏标题、问题标签和选项等场景。

 

#import <UIKit/UIKit.h>

 

@interface UIFont (APCAppearance)

 

+ (UIFont*) appRegularFontWithSize: (CGFloat) size;

+ (UIFont*) appMediumFontWithSize: (CGFloat) size;

+ (UIFont*) appLightFontWithSize: (CGFloat) size;

+ (UIFont*) appNavBarTitleFont;

+ (UIFont*) appQuestionLabelFont;

+ (UIFont*) appQuestionOptionFont;

 

@end

 

 

#import "UIFont+APCAppearance.h"

#import "APCAppearanceInfo.h"

#import "APCConstants.h"

 

@implementation UIFont (APCAppearance)

 

+ (UIFont*) appRegularFontWithSize: (CGFloat) size

{

    return [UIFont fontWithName:[APCAppearanceInfo valueForAppearanceKey:kRegularFontNameKey] size:size];

}

 

+ (UIFont*) appMediumFontWithSize: (CGFloat) size

{

    return [UIFont fontWithName:[APCAppearanceInfo valueForAppearanceKey:kMediumFontNameKey] size:size];

}

 

+ (UIFont*) appLightFontWithSize: (CGFloat) size

{

    return [UIFont fontWithName:[APCAppearanceInfo valueForAppearanceKey:kLightFontNameKey] size:size];

}

 

+ (UIFont*) appNavBarTitleFont {

    return [UIFont appMediumFontWithSize:17.0f];

}

 

+ (UIFont*) appQuestionLabelFont {

    return [UIFont appRegularFontWithSize:17.0f];

}

 

+ (UIFont*) appQuestionOptionFont {

    return [UIFont appRegularFontWithSize:44.0f];

}

 

@end

转载于:https://www.cnblogs.com/wcLT/p/4693556.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值