zoukankan      html  css  js  c++  java
  • 如何更改 iOS7 中的未选定的 tabbaritem 颜色

    此代码在 iOS 7 上工作。
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:10.0f],
    NSForegroundColorAttributeName : [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:1]
    } forState:UIControlStateNormal];

    如你所设置的前景色。
    影响也非选定 tabbar 图标:
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor], UITextAttributeTextColor, nil]
    forState:UIControlStateNormal];

    如果它不工作的唯一方法是用图像的选定和未选定状态:
    // set selected and unselected icons
    UITabBarItem *item = [self.tabBar.items objectAtIndex:0];

    // this way, the icon gets rendered as it is (thus, it needs to be green in this example)
    item.image = [[UIImage imageNamed:@"unselected-icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    // this icon is used for selected tab and it will get tinted as defined in self.tabBar.tintColor
    item.selectedImage = [UIImage imageNamed:@"selected-icon.png"];

     
  • 相关阅读:
    聊一聊HTML <pre>标签
    [Effective JavaScript 笔记]第20条:使用call方法自定义接收者来调用方法
    数据库的权限管理
    完整性约束
    MYSQL
    Python并发编程之协程
    python并发编程之多线程
    python并发编程之多进程
    进程
    网络编程之socket的运用
  • 原文地址:https://www.cnblogs.com/canghaixiaoyuer/p/4987498.html
Copyright © 2011-2022 走看看