4

我想UILabel在我的应用程序的每个视图中更改每个视图的字体,而不需要对每一个(大约 50 个)进行编码。我该怎么做呢?

具体来说,我想知道如何引用 all UILabels

谢谢

4

1 回答 1

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;
}
于 2012-06-07T15:51:51.950 回答