如何引用应用程序中的每个UILabel

gar*_*hdn 4 iphone objective-c ios

我想改变UILabel我的应用程序的每个视图中的每个视图的字体而不编码每一个(大约50).我该怎么做呢?

具体来说,我想知道如何引用所有UILabels.

谢谢

aza*_*arp 8

这可以通过新的iOS 5外观API轻松处理.Appearance API允许您在整个应用程序中更改控件的外观.

请看下面的截图:http://www.youtube.com/watch?v = L63CU2T7DBE&list = UUKvDySsrOVgUgRLhWHeyHJA& index = 4&feature = plcp

这可能有效:

- (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;
}
Run Code Online (Sandbox Code Playgroud)

  • setFont现已弃用.有没有人知道另一种选择? (4认同)