【问题标题】:UISearchBar box colorUISearchBar 框颜色
【发布时间】:2014-09-15 11:39:59
【问题描述】:

我有一个搜索栏,除此之外,我想要一个与搜索栏中的背景颜色相同的按钮。有人知道这个颜色吗?

【问题讨论】:

    标签: ios ios7 colors searchbar


    【解决方案1】:

    我认为它是#A4A4A4 或者你可以试试photoshop中的吸管工具

    【讨论】:

      【解决方案2】:

      只需自定义文本字段本身。

      我只是这样做,它对我来说很好(iOS 7)。

      UITextField *txfSearchField = [_searchBar valueForKey:@"_searchField"];
      txfSearchField.backgroundColor = [UIColor redColor];
      

      这样您就不需要创建图像、调整大小等...

      不使用私有 API:

      for (UIView* subview in [[self.searchBar.subviews lastObject] subviews]) {
          if ([subview isKindOfClass:[UITextField class]]) {
              UITextField *textField = (UITextField*)subview;
              [textField setBackgroundColor:[UIColor redColor]];
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2010-11-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-01
        • 2011-02-16
        • 1970-01-01
        相关资源
        最近更新 更多