【发布时间】:2014-12-03 10:54:08
【问题描述】:
我有一个自定义按钮 AdvisorButton.h 并在 init 中设置了按钮的字体,但我相信它们会被按钮的情节提要设置覆盖。
实现如下:
-(id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
[self initializationCodeMethod];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
if ((self = [super initWithCoder:aDecoder]))
{
[self initializationCodeMethod];
}
return self;
}
-(id)initializationCodeMethod
{
if(self.tag == 1)
{
UIFont *theFont = [UIFont fontWithName:@"DINOT-Light" size:20];
[self.titleLabel setFont:theFont];
}
else
{
UIFont *theFont = [UIFont fontWithName:@"VWHeadlineOT-Book" size:20];
[self.titleLabel setFont:theFont];
}
return self;
}
字体对象已正确初始化,如果我将它们打印出来,则具有值等。
问题是它们是在情节提要中定义的,我想避免在他们的视图控制器中引用每个按钮/标签/文本字段来设置字体。
我认为情节提要的值是在 init 函数调用之后设置的吗?
对这个问题的任何见解都会被证明是有用的!
编辑: 请注意,我在尝试设置之前检查了字体,并将其设置为情节提要中的默认字体,这很好。
然后我在它应该设置后再次检查它,它仍然完全相同。
【问题讨论】:
标签: ios objective-c xcode fonts xcode6.1