zoukankan      html  css  js  c++  java
  • iOS TabbarController 设置底部Toolbar图片和文字颜色选中样式

    提取公共方法:

    -(void)createChildVcWithVc:(UIViewController *)vc Title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
    {
        
        //图片渲染
        vc.tabBarItem.title=title;
        vc.navigationItem.title=title;
        vc.tabBarItem.image=[UIImage imageNamed:image];
        vc.tabBarItem.selectedImage=[[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        //文字渲染
        NSMutableDictionary *dict=[NSMutableDictionary dictionary];
        dict[NSForegroundColorAttributeName]=[UIColor blackColor];
        [vc.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
        
        //选中的文字渲染
        dict[NSForegroundColorAttributeName]=[UIColor orangeColor];
        [vc.tabBarItem setTitleTextAttributes:dict forState:UIControlStateSelected];
        
        YJNavigationController *nav=[[YJNavigationController alloc] initWithRootViewController:vc];
        [self addChildViewController:nav];
    }
    

      

    使用方法:

     YJMeViewController *me=[[YJMeViewController alloc] init];
        [self createChildVcWithVc:me Title:@"我" image:@"tabbar_profile" selectedImage:@"tabbar_profile_selected"];
    

      

  • 相关阅读:
    UVA
    shell 之for循环几种写法
    关于用户的一些操作(useradd与adduser的区别)
    shell 大小关系 -eq -ne
    shell之seq
    脚本函数写法
    Springboot将数据存储到数据库当中
    后端传输数据到前端
    前端传输数据到后端
    JS onFocus和onBlur
  • 原文地址:https://www.cnblogs.com/yajunLi/p/5830696.html
Copyright © 2011-2022 走看看