标签:style blog io color ar os sp for div
iOS7+中UISearchBar会有一层灰色的背景,如果要去除,不需要自定义控件,思路是拿到灰色背景对应的子控件,设置它的背景,需要注意的是iOS7+ 和 iOS7- 中UISearchBar的子视图结构不一样,可参考下面的代码:
1 - (void)removeSearchBarBackground 2 { 3 for (UIView *subView in self.subviews) { 4 if (IsiOS7OrLater) { 5 for (UIView *subSubView in subView.subviews) { 6 if ([subSubView isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { 7 [subSubView removeFromSuperview]; 8 } 9 } 10 } else if ([subView isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { // iOS6以下版本searchBar内部子视图的结构不一样 11 [subView removeFromSuperview]; 12 } 13 } 14 }
标签:style blog io color ar os sp for div
原文地址:http://www.cnblogs.com/lYcHeeM/p/4099716.html