今天要做一个搜索功能,用到UISearchBar 无奈背景太丑,就自定义了一个,首先用View私有方法打印一下searchBar的层次,

(原)iOS 用recursiveDescription打印View-LMLPHP

具体修改代码如下

        for (UIView *view in _topSerachBar.subviews)
{ if ([view isKindOfClass:NSClassFromString(@"UIView")] && view.subviews.count > ) {
[[view.subviews objectAtIndex:] removeFromSuperview];
[[view.subviews objectAtIndex:] setBackgroundColor:[UIColor redColor]];
[[view.subviews objectAtIndex:] setTitle:@"自定义"];
break;
} }
}

(原)iOS 用recursiveDescription打印View-LMLPHP

05-11 19:59
查看更多