Iphone UISearchBarBackground类
我使用以下代码在UISearchBar上隐藏背景: [[searchView.subviews对象索引:0]setHidden:是]; 非常简单,但我担心在子视图列表中硬编码位置。 所以我去寻找UISearchBarBackground.h文件,但找不到它。 有人知道定义隐藏在哪里吗?仅用于 [subView是kindof类:[UISearchBarBackground类]]下面的工作很好: @接口UISearchBarBackground:NSObject{ } @结束 github提供了更完整的定义。只需在 [subView是kindof类:[UISearchBarBackground类]]下面的工作很好: @接口UISearchBarBackground:NSObject{ } @结束Iphone UISearchBarBackground类,iphone,uisearchbar,Iphone,Uisearchbar,我使用以下代码在UISearchBar上隐藏背景: [[searchView.subviews对象索引:0]setHidden:是]; 非常简单,但我担心在子视图列表中硬编码位置。 所以我去寻找UISearchBarBackground.h文件,但找不到它。 有人知道定义隐藏在哪里吗?仅用于 [subView是kindof类:[UISearchBarBackground类]]下面的工作很好: @接口UISearchBarBackground:NSObject{ } @结束 github提供了更完
github提供了一个更完整的定义。对于ios4,它不起作用,所以我尝试了这个,它起作用了 [[self.mysearch.subviews objectAtIndex:0]removeFromSuperview]
对于ios4,它不起作用,所以我尝试了这个,它起作用了 [[self.mysearch.subviews objectAtIndex:0]removeFromSuperview] 另一种方式:
for (UIView* subview in searchControl.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UISearchBarBackground"]) {
[subview removeFromSuperview];
}
}
另一种方式:
for (UIView* subview in searchControl.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UISearchBarBackground"]) {
[subview removeFromSuperview];
}
}
您可以改为使用NSClassFromString方法,以避免仅为测试相等性而创建新类
for (UIView *v in [self.searchbar subviews]) {
if ([v isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
// whatever you want to do with the subview goes here...
}
}
您可以改为使用NSClassFromString方法,以避免仅为测试相等性而创建新类
for (UIView *v in [self.searchbar subviews]) {
if ([v isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
// whatever you want to do with the subview goes here...
}
}
这不是对问题的回答这不是对问题的回答