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;
}
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;
}
相关文章推荐
- Android自动化测试(UiAutomator)简要介绍
- LeetCode-62. Unique Paths/63. Unique Paths II
- WM_QUERYENDSESSION和WM_ENDSESSION
- Java链式方法 连贯接口(fluent interface)
- 【每周一文】Building Text Classifiers Using Positive and Unlabeled Examples(2003)
- StringBuilder使用技巧
- mini2440 -- TFTP方式下载内核镜像(uImage)--开发用
- mini2440 -- TFTP方式下载内核镜像(uImage)--发布用
- 安卓005常用高级UI
- 交互设计师的五大误区
- ubuntu14.04 64位 jd-gui
- android build warning: Ignoring InnerClasses attribute for an anonymous inner class
- poj-3061-subsequence
- treap树---Double Queue
- Android5.0通过Palette来动态决定UI色彩风格
- AbstractQueuedSynchronizer的介绍和原理分析(转)
- UVA LIVE-3263 - That Nice Euler Circuit
- Android消息机制探索(Handler,Looper,Message,MessageQueue)
- ios点击改变uiview背景颜色
- druid数据源配置