UISearchBar

UISearchBar

创建
UISearchBar *searchbar = [UISearchBar alloc]initWihtFream:CGRectMake:(x,y,w,h);

设置控件风格
searchbar.barStyle = UIBarStyleBlack;

设置搜素框的初始文字
searchbar.text = @"";

搜索框背景文字
searchBar.prompt = @""

搜索框内提示文字
search.placeholder = @""

向搜索框添加一个图书按钮
search.showBoookmarkButton = YES;

向搜索框添加一个取消按钮
search.showCancelButton = YES;

展示搜索结果按钮
search.showSearchResultsButton = YES;

设置搜索框光标的颜色
searchBar.tintColor = [UIColor redColor];

设置搜索框边框的颜色
searchBar.barTintColor = [UIColor blueColor];

设置搜索框整体风格
search.searchBarStyle = UISearchBarStyleProminent;

设置搜索框的附加切换试图
searchbar.showsScopeBar = YES;
searchbar.scopeButtonTitles = @[@"buttonOne",@"buttonTwo",@"buttonThree"];
searchbar.selectedScopeButtonIndex = 1;

设置键盘的附加试图
UIview *view = [UIview alloc]initWithFream:CGRectMake:(x,y,375,40)];
view.backgroundColor = [UIColor grayColor];
UILabel *label = [UILabel alloc]initWithFream:CGRectMake:(x,y.w.h)];
label.text =@"用于添加扩展功能";
label.textColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
[view addSubview:label];
searchBar.inputAccessoryView = view;

添加到视图上
[self.view addSubview:searchbar]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值