I have a custom button, AdvisorButton.h and within the init I set the font of the button but I believe they are being overridden by the storyboard settings for the button.
Heres the implementation:
-(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;
}
The font objects are initialised properly and if i print them out the have value etc.
The problem is they are defined in the storyboard and I want to avoid referencing every button/label/textfield in their view controllers just to set the font.
Am I right in thinking that the storyboard values are being set after the init function call?
Any insight into this problem would prove useful!
EDIT: Note that I checked the font before trying to set it, and its set to the default font from the storyboard which is fine.
I then check it again after it is supposedly set and its still the exact same.
Solved
It turns out of the text of the object on the storyboard is anything other than the system default any changes are overridden by the storyboard settings.
I personally had attributed text with underline etc and it did not update.
I removed the attributes but left another font other than default and it failed to replace the font.
Therefore I set it back to default and it then allowed me to replace the font.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다