【发布时间】:2012-07-31 10:02:06
【问题描述】:
我知道在 iOS 5 中可以使用自定义 UITabBarItem
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_sel"]];
tabbar_sel 图像的宽度为 120px (640px/5)。对于横向模式,我需要将其更改为 190x 宽度的图像。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"landscape.");
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_sel_l"]];
} else {
NSLog(@"normal.");
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_sel"]];
}
}
但是,这不起作用,无论是在委托类中还是在 ViewController 中。 我也已经尝试过了,但它会导致崩溃。
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_sel"]
forBarMetrics:UIBarMetricsDefault];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_sel_l"] forBarMetrics:UIBarMetricsLandscapePhone];
【问题讨论】:
标签: iphone cocoa ios5 proxy appearance