Twitter-esque UITabBarController?

后端 未结 5 940
抹茶落季
抹茶落季 2020-12-14 03:51

I\'d like to make an app that uses a UITabBarController that is similar to the one in the Twitter app for iPhone and iPod touch. (Blue light for unread and sliding arrow for

5条回答
  •  时光取名叫无心
    2020-12-14 04:32

    BCTabBarController is what I based my custom twitter style tab-bar on and it works in iOS 4 and 5: http://pastebin.me/f9a876a6ad785cb0b2b7ad98b1024847

    Each tab view controller should implement the following method for the tabs image:

    - (NSString *)iconImageName {
        return @"homeTabIconImage.png";
    }
    

    (In the App delegate) you would initialize the tab bar controller like so:

    self.tabBarController = [[[JHTabBarController alloc] init] autorelease];
    self.tabBarController.delegate = self;
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:
                                             [[[UINavigationController alloc] initWithRootViewController:[[[iPhoneHomeViewController alloc] init] autorelease]] autorelease],
                                             [[[UINavigationController alloc] initWithRootViewController:[[[iPhoneAboutUsViewController alloc] init] autorelease]] autorelease],
                                             [[[UINavigationController alloc] initWithRootViewController:[[[iPhoneContactInfoViewController alloc] init] autorelease]] autorelease],
                                             [[[UINavigationController alloc] initWithRootViewController:[[[iPhoneMapUsViewController alloc] init] autorelease]] autorelease],
                                             [[[UINavigationController alloc] initWithRootViewController:[[[iPhoneCreditsViewController alloc] init] autorelease]] autorelease],
                                                 nil];
    

    Optionally, you can use a custom background image for each tabs view controller with this method:

    - (UIImage *)tabBarController:(JHTabBarController *)tabBarController backgroundImageForTabAtIndex:(NSInteger)index {
        NSString *bgImagefilePath;
        switch (index) {
            case 0:
                bgImagefilePath = @"homeBG.png";
                break;
            case 1:
                bgImagefilePath = @"aboutBG.png";
                break;
            case 2:
                bgImagefilePath = @"contactBG.png";
                break;
            case 3:
                bgImagefilePath = @"mapBG.png";
                break;
            case 4:
                bgImagefilePath = @"creditsBG.png";
                break;
            default:
                bgImagefilePath = @"homeBG.png";
                break;
        }
        return [UIImage imageNamed:bgImagefilePath];
    }
    

    The arrow at the top of the tab bar slides across to the tab that is selected just like the twitter tab bar.

    Some screenshots:

    BCTabBarController BCTabBarController

提交回复
热议问题