在iPad中使用带有UISearchBar的UISearchDisplayController时,它会显示在UIPopoverController中。我想覆盖图像上显示的清除按钮以进一步修复。如果不可能,我该如何删除清除按钮?
答案 0 :(得分:0)
我做了一次..我用自定义按钮替换了清除按钮以进行自定义操作..请检查此
UISearchBar *searchBar = yourSearchController.searchBar;
UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
UIButton *cButton = [UIButton buttonWithType:UIButtonTypeCustom];
cButton.frame = CGRectMake(0, 0, 20 , 20);
cButton.backgroundColor = [UIColor clearColor];
[cButton setImage:[UIImage newImageFromResource:@"yourButtonImage"] forState:UIControlStateNormal];//your button image.
cButton.contentMode = UIViewContentModeScaleToFill;
[cButton addTarget:self action:@selector(customButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event
[searchtextfield setRightView:cButton];
[searchtextfield setRightViewMode:UITextFieldViewModeAlways];
祝你好运。