Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference every UILabel in an application

I'd like to change the font of every UILabel in every view of my application without coding every single one (about 50). How would i go about doing this?

Specifically, i'd like to know how to reference all UILabels.

Thanks

like image 305
garethdn Avatar asked Feb 20 '23 05:02

garethdn


1 Answers

This can easily be handled by the new iOS 5 appearance API. Appearance API allows you to change the appearance of the control throughout the application.

Take a look at my screenshot below: http://www.youtube.com/watch?v=L63CU2T7DBE&list=UUKvDySsrOVgUgRLhWHeyHJA&index=4&feature=plcp

This might work:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UILabel appearance] setFont:[UIFont fontWithName:@"Marker Felt" size:56]];

    [[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:@"Marker Felt" size:10]];

    [[UINavigationBar appearance] setTintColor:[UIColor blueColor]];

    return YES;
}
like image 153
azamsharp Avatar answered Feb 25 '23 22:02

azamsharp