CustomSearchBar颜色与UINavigationBar中的颜色不同

时间:2014-07-03 21:07:55

标签: objective-c ios7 uinavigationbar uisearchbar

我正在使用:

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

在customSearchView init中:

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

获得下一个结果:

enter image description here

我需要searchBarTint颜色与导航相同。半透明似乎没有成功。

1 个答案:

答案 0 :(得分:0)

我在发布问题后不久就提出了修复方法。

如果有人遇到过这个问题我使用了

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

自iOS 7以来,似乎backgroundColor和barTintColor的颜色与UISearchDisplayController的导航颜色不同。但添加具有该颜色的图像只是解决了这个问题。

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