更改UISearchBar button属性
//點擊搜索框時觸發
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
? ? self.theSearchUserSearchBar.showsCancelButton = YES; //很關鍵
?? ?
? ? UIView *topView = self.theSearchUserSearchBar.subviews[0];
?? ?
? ? for (UIView *searchbuttons in topView.subviews)
? ? {
? ? ? ? if ([searchbuttons isKindOfClass:NSClassFromString(@"UINavigationButton")])//NSClassFromString(@"UINavigationButton")
? ? ? ? {
? ? ? ? ? ? UIButton *cancelButton = (UIButton*)searchbuttons;
? ? ? ? ? ? cancelButton.enabled = YES;
? ? ? ? ? ? [cancelButton setTitle:@"確定" forState:UIControlStateNormal];
? ? ? ? ? ? break;
? ? ? ? }
? ? }
?
?
?? ?
? ? return YES;
}
?
所以,同理可以更改 UISearchBar上面的任意view。
?
總結
以上是生活随笔為你收集整理的更改UISearchBar button属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Activity、Task、应用和进程
- 下一篇: 学习如何写PHP MVC框架(1) --