UISearchBar の [キャンセル] ボタンの背景を変更する次のコードがあります。
for( UIView *subview in self.searchBar.subviews ){
if ([subview isKindOfClass:[UIButton class]]) {
[(UIButton *)subview setEnabled:YES];
[(UIButton *)subview setTitle:@"New Button Text" forState:UIControlStateNormal];
((UIButton *)subview).tintColor = [UIColor colorWithRed:4/255.0 green:119/255.0 blue:152/255.0 alpha:1.0];
}
}
問題は、このコードが iOS7 で動作しないことです! UISearchBar のビューの構造で何が変更されましたか?
編集:ここでテストされ、これは UISearchBar の新しい階層です:
UISearchBar:
---UIView:
------UISearchBarBackground
------UISearchBarTextField
------UINavigationButton
問題は、テストできないことif ([sub isKindOfClass:[UINavigationButton class]])
です。この行はコンパイル エラーをスローします。Use of undeclared identifier: UINavigationButton