iOS-去掉UISearchBar背景

iOS系统去掉UISearchBar背景。

// IOS 7
if ([self.searchBar respondsToSelector:@selector(barTintColor)]) {
    [self.searchBar setBarTintColor:[UIColor whiteColor]];
}
// IOS 6
else{
    for (UIView *subview in self.searchBar.subviews) {
        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
            [subview removeFromSuperview];
            break;
        }
    }
}
YI wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!