在NavigtionBar上设置 UISearchBar

来源:互联网 发布:预算计价软件 编辑:程序博客网 时间:2024/05/17 06:03

<span style="font-family:Times New Roman;font-size:18px;">self.searchBar = [[[UISearchBar alloc] init] autorelease];    self.searchBar.barTintColor = [UIColor whiteColor];    _searchBar.frame = CGRectMake(0, 0, 200, 25);    //设置圆角    _searchBar.layer.cornerRadius = 12.5;    _searchBar.layer.masksToBounds = YES;    [_searchBar.layer setBorderWidth:0.5];    [_searchBar.layer setBorderColor:[UIColor blackColor].CGColor];  //设置边框为白色    //设置titleView    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 25)];//allocate titleView    [titleView setBackgroundColor:[UIColor whiteColor]];    [titleView addSubview:_searchBar];    self.navigationItem.titleView = titleView;        _searchBar.placeholder = @"请输入搜索内容";</span>

0 0