我希望自定义应用程序中的所有字体,并且一直在使用 [UILabel Appearance]
API,因为它看起来是阻力最小的路径。
我注意到这也会影响 UIAlertView
内部的标签(如预期),但我也知道自定义警报 View 可能会导致应用被拒绝。
有没有人有这方面的经验?我是否应该创建自己的 UILabel
子类,然后手动将其应用到应用程序中的每个标签?
最佳答案
UILabel 类符合 UIAppearanceContainer 协议(protocol),查看 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
关于ios - 在 UILabel 上使用外观代理是否会因为更改 UIAlertView 而拒绝我的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24614652/