阅读背景:

iOS 原生UITabBarController 的tabbar 图标状态自定义

来源:互联网 
SellerViewController *sellerVC = [[SellerViewController alloc] initWithNibName:nil bundle:nil];
    BaseNavigationViewController *sellerNav = [[BaseNavigationViewController alloc] initWithRootViewController:sellerVC];
    sellerVC.tabBarItem.title = @"商家";
    sellerVC.tabBarItem.image = [UIImage imageNamed:@"tabbar1_normal"];
    sellerVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar1_select"];
    [sellerVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabbar1_select"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar1_normal"]];;

    
    CardViewController *cardVC = [[CardViewController alloc] initWithNibName:nil bundle:nil];
    BaseNavigationViewController *cardNav = [[BaseNavigationViewController alloc] initWithRootViewController:cardVC];
    cardVC.tabBarItem.title = @"名片夹";
    [cardVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabbar2_select"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar2_normal"]];;
    
    
    LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:nil bundle:nil];
    BaseNavigationViewController *loginNav = [[BaseNavigationViewController alloc] initWithRootViewController:loginVC];
    loginVC.tabBarItem.title = @"我的";
    [loginVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabbar3_select"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar3_normal"]];;

    
    
    _tabBarController = [[BaseTabBarViewController alloc] init];
    self.tabBarController.viewControllers = [[NSMutableArray alloc] initWithObjects:sellerNav,cardNav,loginNav, nil];
    self.tabBarController.selectedIndex = 0;
    
    self.window.rootViewController = self.tabBarController;

    //tabBar 背景颜色
    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar_bg.png"]];
    //Tabbar 的遮罩层给一个空的image
    [[UITabBar appearance] setSelectionIndicatorImage:[[[UIImage alloc] init] autorelease]];
    
    //字体颜色,UIControlStateNormal
    [[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor colorWithWhite:141.0/255.0 alpha:1.0 ], UITextAttributeFont : [UIFont boldSystemFontOfSize:10.0] }
                                             forState:UIControlStateNormal];
    
    //字体颜色 UIControlStateSelected
    [[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor blackColor], UITextAttributeFont : [UIFont boldSystemFontOfSize:10.0] }
                                             forState:UIControlStateSelected];
    [sellerVC release];
    [sellerNav release];
    [cardVC release];
    [cardNav release];
    [loginVC release];
    [loginNav release];
SellerViewController *sellerVC = [[SellerViewCo



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: