Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell appearance not changing textLabel font

I have the following code in my didFinishLaunchingWithOptions function :

[[[UITableViewCell appearance] textLabel]setFont:[UIFont fontWithName:@"someFont" size:12]];

But for some reason this does not change the text in my table cells.

If in the table delegate function cellForRowAtIndexPath I add

cell.textLabel.font = [UIFont fontWithName:@"someFont" size:12];

It does change the font to my desired one.

Any ideas?

like image 861
oopsi Avatar asked Feb 26 '14 12:02

oopsi


1 Answers

Setting the font property of a UITableViewCell is not supported using the appearance proxy.

You can tell which properties are supported by looking in the header file for that class for UI_APPEARANCE_SELECTOR.

Take a look at UITableViewCell.h and you'll see that only separatorInset is supported (and backgroundColor as this is supported by its superclass, UIView):

@property (nonatomic) UIEdgeInsets separatorInset NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR; // allows customization of the separator frame


From the UIAppearance protocol reference:

To support appearance customization, a class must conform to the UIAppearanceContainer protocol and relevant accessor methods must be marked with UI_APPEARANCE_SELECTOR.

like image 50
Ashley Mills Avatar answered Sep 19 '22 02:09

Ashley Mills