1

我是新手Objective-C,我正在尝试删除 a 的背景UISearchBar以将我的一个图像用于textfield,但是一旦删除它,它就会UISegmentedControl 在背景中显示 a 。

for (UIView *subview in [projectSearch subviews]) {
        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
        {
            [subview removeFromSuperview];
        }

        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarTextField")]) {
            [(UITextField *)subview setBackground:[UIImage imageNamed:@"pg-14-search-field.png"]];
        }
    }

UISegmentedControl删除UISearchBar背景后如何防止出现?

4

1 回答 1

0
for (UIView *view in self.searchBar.subviews) {
    for (UIView *subview in view.subviews) {
        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
        {
            [subview removeFromSuperview];
        }

        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarTextField")])
        {

        }
    }
}
于 2014-08-07T02:38:50.303 回答