0

什么是创建完全自定义UITabBarController外观的最佳方式。

我需要完全自定义它的大小,为其设置动画等。

我的解决方案只是使用UIViewtabbarcontroller ,然后UIView根据在上面选择的按钮替换上面的它UIView

最好的方法是什么?

4

1 回答 1

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];
    }
}
于 2013-05-28T20:27:10.500 回答