How do I remove the setting of UIAppearance already set in UILabel?
Or How do I update already set up UIAppearance?
I created a custom defined UILabel method as follows.
Header
- (void)setAppearanceFont:(UIFont *)font UI_APPEARANCE_SELECTOR;
Implementation
- (void)setAppearanceFont:(UIFont *)font
{
_invokeCount += 1;
NSLog(@"invokeCount: %ld", _invokeCount);
self.font = font;
}
If I set up appearance twice, setAppearanceFont method was invoked twice.
// set appearance
[[MyAppearanceLabel appearance] setAppearanceFont:font];
....
....
// set appearance from another timing
[[MyAppearanceLabel appearance] setAppearanceFont:font];
// show label
MyAppearanceLabel label* = [[MyAppearanceLabel alloc]
initWithFrame:CGRectMake(0, 0, 100, 100)];
[self.view addSubview:label]; // <= invoked twice here!!
I want to ensure that the setAppearance method is invoked only once.
In swift 4 i do as follow(just setting nil to it):
UILabel.appearance(whenContainedInInstancesOf: [UITableViewCell.self]).textColor = nil