pie*_*phi 1 customization uitabbaritem uitabbar ios5
由于iOS 5的苹果公司提供的API来定制UITabBarItems
的UITabBar
对象.我具体指的是以下选择器:
setFinishedSelectedImage:withFinishedUnselectedImage:
这一切都适用于常规按钮,但我似乎无法自定义"更多"按钮以匹配其他按钮的样式.这就是我在做的事情:
tabBarController.viewControllers = tabBarControllerArray;
tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
UITabBarItem *more = tabBarController.moreNavigationController.tabBarItem;
if ([more respondsToSelector:@selector(setFinishedSelectedImage:withFinishedUnselectedImage:)]){
[more setFinishedSelectedImage:[UIImage imageNamed:@"BarIcon-More.png"]
withFinishedUnselectedImage:[UIImage imageNamed:@"BarIcon-More.png"]
];
} else {
more.image = [UIImage imageNamed:@"BarIcon-More.png"];
}
Run Code Online (Sandbox Code Playgroud)
结果如下,它不会提取我的自定义更多图像.
我已经看到很多黑客可以替换更多的按钮但是必须有更好的方法来做到这一点吗?
解决方案很愚蠢.
我认为是UITabBarItems
在moreNavigationController
readonly,它不是.所以只需执行以下操作:
tabBarController.moreNavigationController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"More" image:[UIImage imageNamed:@"BarIcon-More.png"] tag:0];
Run Code Online (Sandbox Code Playgroud)
和上面相同的自定义代码有效.
归档时间: |
|
查看次数: |
3317 次 |
最近记录: |