zoukankan      html  css  js  c++  java
  • 给tabBar设置图片和字体颜色的几种方法

    • 现在很多应用都使用到了tabBar,我们往往在给tabBar设置图片和字体的时候,当选中状态下,往往字体的颜色和图片的颜色不匹配,有时候就显得无从下手,我也常常忘了,所有写这个博客的目的,相当于给自己做个笔记,也希望给有需要的朋友们一点帮助。写了个小demo,来演示这个问题:

      • 写了个小demo,来演示这个问题:

      •  - (void)viewDidLoad {
            [super viewDidLoad];
        
            ZYGroupBuyViewController *group = [[ZYGroupBuyViewController alloc]init];
            [self createVC:group Title:@"团购" imageName:@"icon_tabbar_homepage"];
        
            ZYVisitTableViewController *visit = [[ZYVisitTableViewController alloc]init];
            [self createVC:visit Title:@"上门" imageName:@"icon_tabbar_onsite"];
        
            ZYBusinessViewController *business = [[ZYBusinessViewController alloc]init];
            [self createVC:business Title:@"商家" imageName:@"icon_tabbar_merchant"];
        
            ZYProfileViewController *profile = [[ZYProfileViewController alloc]init];
            [self createVC:profile Title:@"我的" imageName:@"icon_tabbar_mine"];
        
            ZYMoreViewController *more = [[ZYMoreViewController alloc]init];
            [self createVC:more Title:@"更多" imageName:@"icon_tabbar_misc"];
        
        }
        
        • 第一种方法:
        •   [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:68/255.0 green:173/255.0 blue:159/255.0 alpha:1]} forState:UIControlStateSelected];
          
        • 第二种方法
        • self.tabBar.tintColor = [UIColor colorWithRed:68/255.0 green:173/255.0 blue:159/255.0 alpha:1];
          
  • 相关阅读:
    three.js_ "Failed to execute 'texImage2D' on 'WebGLRenderingContext': tainted canvases may not be loded."
    three.js为何如此奇妙
    npm install ERR! code E400/E404
    小程序_请求封装network
    css_input[checked]复选框去掉默认样式并添加新样式
    【CSS】凹槽的写法
    剑指Offer_编程题_6
    剑指Offer_编程题_5
    剑指Offer_编程题_4
    剑指Offer_编程题_3
  • 原文地址:https://www.cnblogs.com/GJ-ios/p/6068414.html
Copyright © 2011-2022 走看看