Sarreph
Sarreph

Reputation: 2015

Alternatives to appearance proxy for Table Cells' UILabel setFont

I'm loving being able to use an appearance proxy in my iOS5 app to customise the NavigationController UI elements system-wide, however:

I have a lot of nested tables in my app, of which I'd love to be able to change the font across all table cells. They are mainly statically created. I've put some cell generation inside of a class, being read from an array, but the main issue lies with a large contents section I've tabled in Interface Builder. IB doesn't seem to have the option for mass-font setting.

I was wondering if anyone could help me find a way to set all the UITableCell fonts in one go?

Perhaps something like:

[[UILabel appearance] setFont:[UIFont fontWithName:@"Times" size:17.00];

Upvotes: 9

Views: 2711

Answers (2)

Joshua J. McKinnon
Joshua J. McKinnon

Reputation: 1696

Actually, no. It is not valid to use UIAppearance to style a UILabel. See my self-answered question here. It kinda works, but it's not valid, for the reasons outlined over there.

Upvotes: 2

Mike Katz
Mike Katz

Reputation: 2080

You can use appearanceWhenContainedIn: to narrow down which UIViews you'd like to set the appearance for.

In your example, try:

[[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] 
          setFont:[UIFont fontWithName:@"Times" size:17.00]];

Upvotes: 8

Related Questions