zoukankan      html  css  js  c++  java
  • IOS 改变tabbar的样式

    1、改变默认的背景(背景色)
    [[UITabBar appearance] setBackgroundImage:[UIImage imageFromColor:[UIColor colorWithR:50 G:66 B:81] forSize:CGSizeMake(SCREEN_WIDTH, MAIN_TABBAR_HEIGHT) withCornerRadius:0]];
    

    2、改变选中的背景(背景色)

    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageFromColor:[UIColor colorWithRed:49/255.0 green:158/255.0 blue:141/255.0 alpha:1] forSize:CGSizeMake(SCREEN_WIDTH / 4, MAIN_TABBAR_HEIGHT) withCornerRadius:0]];
    

    3、改变默认的图片的前景色

    [[UITabBar appearance] setTintColor:[UIColor whiteColor]];

        注:此方法会导致所有颜色,或者说所有非透明的地方都变成设置的颜色。

        而当设置tabbaritem的image选项的时候,如果使用 

    controller.tabbaritem.image = [[UIImage imageNamed:@"tabbar_item_group"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
    

      这样的话,setTintColor 是不起作用的。

    4、设置选中的图片的前景色

    [[UITabBar appearance] setSelectedImageTintColor:MAIN_COLOR];
    

      注:此方法会导致所有颜色,或者说所有非透明的地方都变成设置的颜色。

          而当设置tabbaritem的selectedimage选项的时候,如果使用 

    controller.tabbaritem.selectedimage = [[UIImage imageNamed:@"tabbar_item_group"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
    

      这样的话,setSelectedImageTintColor 是不起作用的。

    5、设置tabbar字体的颜色

     //设置默认时的字体颜色
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal]; //设置选中时的字体颜色 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:MAIN_COLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];

      同理,这里修改  NSForegroundColorAttributeName  为 NSFontAttributeName、NSUnderlineStyleAttributeName等,可以修改这些字体不同的属性。

  • 相关阅读:
    提示35. 怎样实现OfTypeOnly<TEntity>()这样的写法
    (翻译)Entity Framework技巧系列之十
    Entity Framework教程(第二版)
    实战 ASP.NET Web API
    Apache,PHP,MySQL的安装,配置
    Apache配置虚拟目录和多主机头
    web.config配置详细说明
    百度UEditor编辑器使用教程与使用方法
    若要调试此模块,请将其项目生成配置更改为“调试”模式。若要取消显示此消息,请禁用“启动时若没有用户代码则发出警告”调试器选项
    jquery筛选器
  • 原文地址:https://www.cnblogs.com/sdwdjzhy/p/5462201.html
Copyright © 2011-2022 走看看