美文网首页
UITabBar属性的设置

UITabBar属性的设置

作者: 为什么划船不靠桨 | 来源:发表于2017-04-27 09:42 被阅读0次

    这些内容通常写在+initialize方法里

    //首先拿到UITabBar
    UITabBar * tab = [UITabBar appearance];
    //背景颜色
    //tab.barTintColor = [UIColor yellowColor];
    //前景颜色
    //tab.tintColor = [UIColor orangeColor];
    //设置背景图片
    [tab setBackgroundImage:[UIImage imageNamed:@"tabbar"]];
    //设置透明度
    tab.alpha = 0.3;
    // UIControlStateNormal状态下的文字属性
     NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
    //文字颜色
    dictionary[NSForegroundColorAttributeName] = [UIColor blackColor];
    //文字大小
    dictionary[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    
    // UIControlStateSelected状态下的文字属性
    NSMutableDictionary * seleDictionary = [NSMutableDictionary dictionary];
    seleDictionary[NSForegroundColorAttributeName] = [UIColor colorWithRed:255 / 256.0 green:255 / 256.0  blue:130 / 256.0 alpha:1];
    
    UITabBarItem * itme = [UITabBarItem appearance];
    [itme setTitleTextAttributes:dictionary forState:UIControlStateNormal];
    [itme setTitleTextAttributes:seleDictionary forState:UIControlStateSelected];
    //每一个控制器都有tabBarItem这个属性
    childController.tabBarItem.image = [UIImage imageNamed:image];
    childController.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
    childController.tabBarItem.badgeValue = @"11";
    //设置消息标题的字体大小
    [item setBadgeTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25]} forState:UIControlStateNormal];
    
    

    相关文章

      网友评论

          本文标题:UITabBar属性的设置

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