Ios 向uisearchbar添加刷新徽标
有没有可能在iPad的uisearchbar上添加像safari中那样的刷新徽标? 喜欢下面的图片吗 我有一个uisearchbarcontroller和一个uitableview。想知道是否可以像刷新一样添加箭头。可以添加搜索结果和书签Ios 向uisearchbar添加刷新徽标,ios,xcode,ipad,Ios,Xcode,Ipad,有没有可能在iPad的uisearchbar上添加像safari中那样的刷新徽标? 喜欢下面的图片吗 我有一个uisearchbarcontroller和一个uitableview。想知道是否可以像刷新一样添加箭头。可以添加搜索结果和书签 谢谢。是的,你可以。。您需要将清除按钮替换为自定义按钮,以执行刷新操作。。下面是实现这一点的代码 UISearchBar *searchBar = yourSearchBar; UITextField *searchtextfield = [searchBa
谢谢。是的,你可以。。您需要将清除按钮替换为自定义按钮,以执行刷新操作。。下面是实现这一点的代码
UISearchBar *searchBar = yourSearchBar;
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];//refresh image.
cButton.contentMode = UIViewContentModeScaleToFill;
[cButton addTarget:self action:@selector(refreshButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event(refresh)
[searchtextfield setRightView:cButton];
[searchtextfield setRightViewMode:UITextFieldViewModeAlways];
享受:)是的,你可以。。您需要将清除按钮替换为自定义按钮,以执行刷新操作。。下面是实现这一点的代码
UISearchBar *searchBar = yourSearchBar;
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];//refresh image.
cButton.contentMode = UIViewContentModeScaleToFill;
[cButton addTarget:self action:@selector(refreshButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event(refresh)
[searchtextfield setRightView:cButton];
[searchtextfield setRightViewMode:UITextFieldViewModeAlways];
享受:)对于iOS 7,请更换:
UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
与:
对于iOS 7,请替换:
UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
与: