在我的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版本上检查此功能是否可用,以便我可以避免崩溃?
答案 0 :(得分:19)
请勿检查操作系统,检查功能是否存在。
if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {}
答案 1 :(得分:1)
试试这个:
[UIDevice currentDevice].systemVersion