我希望自定义应用程序中的所有字体,并且一直在使用该[UILabel appearance]
API,因为它看起来像是阻力最小的路径。我注意到,这也会影响UIAlertView
(如预期的那样)内部的标签,但是我也意识到自定义警报视图可能会导致应用程序被拒绝。
有人对这个有经验么?我应该自己UILabel
代替自己的子类,然后手动将其应用于应用程序中的每个标签吗?
UILabel类符合UIAppearanceContainer协议,对UILabel.h的检查显示其属性均未标记为UI_APPEARANCE_SELECTOR,这是使用UIAppearance的前提。因此,您需要创建UILabel子类,如下所示。
@interface SmallLabel : UILabel
@end
@implementation SmallLabel
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
@结尾
我认为您也可以在子类中尝试类似的方法:
UIFont *newFont = [UIFont fontWithName:@"YourFontName" size:self.font.pointSize];
self.font = newFont
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句