在我的 AppDelegate 中,我使用外观代理来制作自定义 UI:
//Setup custom appearances
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
[[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
这将在 iOS4 中崩溃。如何检查此功能在他们运行的 iOS 版本上是否可用,从而避免崩溃?