UISearchbar的取消button的图像
可能重复:
在UISearchBar中设置取消button的样式
我试图为search栏设置图像,我可以使用search栏的子视图UISearchBarBackground
来设置search栏的图像,但是我无法为search栏的取消button设置图像。 我得到的search栏子视图UINavigationButton
的button,但我知道如何设置UINavigationButton
图像。 谁能帮我?
先谢谢你
试试这个代码…
for (UIView *searchbuttons in searchBar.subviews) { if ([searchbuttons isKindOfClass:[UIButton class]]) { UIButton *cancelButton = (UIButton*)searchbuttons; cancelButton.enabled = YES; [cancelButton setBackgroundImage:[UIImage imageNamed:@"yourImageName"] forState:UIControlStateNormal]; break; } }