【问题标题】:CustomSearchBar color differs from the one in UINavigationBarCustomSearchBar 颜色与 UINavigationBar 中的颜色不同
【发布时间】:2014-07-03 21:07:55
【问题描述】:

我正在使用:

#define colorApp  [UIColor colorWithRed:254/256.f green:64/256.f blue:89/256.f alpha:1.0]

在 customSearchView 内部:

    [self setBackgroundColor:colorApp];
    searchBar = [[UISearchBar alloc] initWithFrame:frame];
    searchBar.barTintColor = colorApp;
    [self addSubview:searchBar];

得到下一个结果:

我需要 searchBarTint 颜色与导航相同。半透明似乎无法奏效。

【问题讨论】:

    标签: objective-c ios7 uinavigationbar uisearchbar


    【解决方案1】:

    我在发布问题后不久就提出了解决方案。

    如果有人遇到这个问题,我会使用

     [self.searchDisplayController.searchBar setBackgroundImage:[UIImage imageNamed:@"pinkBar.png"]
                                                    forBarPosition:0
                                                        barMetrics:UIBarMetricsDefault];
    

    从 iOS 7 开始,backgroundColor 和 barTintColor 似乎不像 UISearchDisplayController 的导航那样采用颜色。但是添加具有该颜色的图像就可以解决这个问题。

    我知道这只是一个快速修复,但它帮助了我并且可以帮助其他人,因为它是一个小的视觉问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-13
      • 2015-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多