UISearchBar的颜色不同?

时间:2016-07-20 10:42:33

标签: ios objective-c uinavigationbar uisearchbar

以下是自定义searchBar中嵌入的navigationBar的代码。我为tintColornavigationBar设置了相同的searchBar。看来tabbar的色调颜色和导航条色调颜色有些不同。可能是什么问题?

enter image description here

- (void)viewdidLoad:(BOOL)animated
{
    //Change the navigation bar color
    [self.navigationController.navigationBar setBarTintColor:kAppNavigationItemGrayColor];

    //Create a UISearchBar
    UISearchBar *topBarSearchBar = [[UISearchBar alloc] init];
    [topBarSearchBar setBarTintColor:kAppNavigationItemGrayColor];

    //Wrapper view to hold searchbar
    UIView *searchBarWrapper = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 310.0, 44.0)];
    [topBarSearchBar setFrame:CGRectMake(0.0, 0.0, 310.0, 44.0)];
    [searchBarWrapper setBackgroundColor:[UIColor clearColor]];
    [searchBarWrapper addSubview:self.topBarSearchBar];
    [self.navigationItem setTitleView:searchBarWrapper];
    self.navigationItem.hidesBackButton = YES;
}

2 个答案:

答案 0 :(得分:0)

试试这个todoTable

答案 1 :(得分:0)

尝试设置,

 self.navigationController.navigationBar.translucent = NO;