gpt4 book ai didi

ios - ios搜索栏能够添加取消图像但不正确

转载 作者:行者123 更新时间:2023-12-01 16:38:43 25 4
gpt4 key购买 nike

在IOS searchBar中,我能够添加取消图像并删除文本,但是一个问题是当我的searchBar Bar着色颜色清除后,我的图像没有显示出来,并且我必须清除UI的着色栏中的颜色
我必须在搜索栏取消按钮中添加图像
这是我的代码

-(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller{
self.searchDisplayController.searchBar.showsCancelButton = YES;
UIButton *cancelButton;
UIView *topView = self.searchDisplayController.searchBar.subviews[0];
for (UIView *subView in topView.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
cancelButton = (UIButton*)subView;
}
}
if (cancelButton) {
//Set the new title of the cancel button
[cancelButton setTitle:@" " forState:UIControlStateNormal];

// [cancelButton setBackgroundColor:[UIColor redColor]];
[cancelButton setImage:[UIImage imageNamed:@"close_icon.png"] forState:UIControlStateNormal];


}
}

清除色条后颜色

请给我解决方案......
有什么希望请帮助我..............
请帮助,有5天完成,我没有任何解决方案

最佳答案

将这种方法放入搜索栏代表中。您不需要添加图像

(void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar1
{
[searchBar setShowsCancelButton:YES animated:YES];
}

关于ios - ios搜索栏能够添加取消图像但不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26057050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com