您的位置:首页 > 产品设计 > UI/UE

SearchBar放至UINavigationBar

2016-04-12 23:19 387 查看
- (void)createSearchBarView {

UIView *titleView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,CGRectGetWidth([UIScreen
mainScreen].bounds)-120,35)];

UIColor *color = self.navigationController.navigationBar.backgroundColor;

[titleView setBackgroundColor:color];

UISearchBar *searchBar = [[UISearchBaralloc]init];

searchBar.delegate =self;

searchBar.frame =CGRectMake(0,0,CGRectGetWidth(titleView.frame),35);

searchBar.backgroundColor = color;

searchBar.layer.cornerRadius =18;

searchBar.layer.masksToBounds =YES;

[searchBar.layersetBorderWidth:8];

[searchBar.layersetBorderColor:[UIColorwhiteColor].CGColor];

searchBar.placeholder = @"搜索商品";

[titleView addSubview:searchBar];

//Set to titleView

[self.navigationItem.titleViewsizeToFit];

self.navigationItem.titleView = titleView;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: