美文网首页
iOS底部导航栏RDVTabBarController

iOS底部导航栏RDVTabBarController

作者: MarcoRe | 来源:发表于2019-10-23 11:07 被阅读0次
效果.png
RDVTabBarController *tabBar = [RDVTabBarController new];
[tabBar setViewControllers:@[na_home,na_tre,na_pub,na_friend,na_my]];
[self customizeTabBarForController:tabBar];
self.window.rootViewController = tabBar;
- (void)customizeTabBarForController:(RDVTabBarController *)tabBarController{
    
    NSArray *tabBarItemTitle = @[@"首页",@"财富",@"口碑",@"朋友",@"我的"];
//    选中效果的图片
    NSArray *tabBarItemImgSelect = @[@"zfb_c",@"caifu_c",@"koubei_c",@"friend_c",@"wode_c"];
//    未选效果的图片
    NSArray *tabBarItemImgUnselect = @[@"zfb_nc",@"caifu_nc",@"koubei_nc",@"friend_nc",@"wode_nc"];
    
    int index = 0;
    for(RDVTabBarItem *item in [[tabBarController tabBar] items])
    {
        item.title = tabBarItemTitle[index];
        [item setFinishedSelectedImage:[UIImage imageNamed:tabBarItemImgSelect[index]] withFinishedUnselectedImage:[UIImage imageNamed:tabBarItemImgUnselect[index]]];
        
        item.unselectedTitleAttributes = @{
                                           NSFontAttributeName:[UIFont systemFontOfSize:11*kFontScale],
                                           NSForegroundColorAttributeName:rgba(156, 156, 156, 1),
                                           };
        item.selectedTitleAttributes = @{
                                         NSFontAttributeName:[UIFont systemFontOfSize:11*kFontScale],
                                         NSForegroundColorAttributeName:[UIColor blueColor],
                                         };
        
        index ++;
    }
}

相关文章

网友评论

      本文标题:iOS底部导航栏RDVTabBarController

      本文链接:https://www.haomeiwen.com/subject/ubuhvctx.html