首页 > 其他 > 详细

在UINavigation上添加UISearchBar

时间:2015-08-20 14:35:35      阅读:153      评论:0      收藏:0      [点我收藏+]

在UINavigation上添加UISearchBar的方法

代码如下:

 

 1 // 创建UIView
 2     UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, 250, 54)];
 3     [self.view addSubview:view];
 4     // 创建搜索栏
 5     UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 10, 250, 30)];
 6     /**
 7      *  setTranslucent如果设置成no,则状态栏及导航样不为透明的,界面上的组件就是紧挨着导航栏显示了,所以就不需要让第一个组件在y方向偏离44+20的高度了
 8      */
 9     [searchBar setTranslucent:NO];
10     searchBar.placeholder = @"请输入需要查询的商品";
11     [view addSubview:searchBar];
12     // 添加导航栏
13     UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 64)];
14     UINavigationItem *item = [[UINavigationItem alloc] init];
15     item.titleView = view;
16     [navigationBar pushNavigationItem:item animated:YES];
17     [self.view addSubview:navigationBar];

 

在UINavigation上添加UISearchBar

原文:http://www.cnblogs.com/aggie/p/4744749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!