创建完全自定义UITabBarController
外观的最佳方式是什么?
我需要完全自定义其大小,动画等等。
我所拥有的解决方案是使用UIView
作为tabbarcontroller,然后根据UIView
上选择的按钮替换其上方的UIView
。
最好的方法是什么?
答案 0 :(得分:0)
这是一个非常好的指南: http://www.felipecypriano.com/2012/02/27/how-to-customize-uitabbar-on-ios-5/
此示例取自该网站:
基本上创建一个backgroundImage,selectionIndicatorImage,根据需要调整字体。
// Probably put these in your AppDelegate, setup the background and selection image
[[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"background"]];
[[[self tabBarController] tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"selected"]];
// In your VC which is inside the tab bar
- (id)init {
self = [super initWithNibName:@"MyNibName" bundle:nil];
if (self) {
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"The Title" image:nil tag:0];
[[self tabBarItem] setFinishedSelectedImage:[UIImage imageNamed:@"tab_icon"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_icon"]];
[[self tabBarItem] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
}
}