UIView *View = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 35)];
UIColor *color = self.navigationController.navigationBar.barTintColor;
[View setBackgroundColor:color];
searchBar = [[UITextField alloc] init];
searchBar.frame = CGRectMake(0, 0, 200, 35);
searchBar.backgroundColor = color;
searchBar.layer.cornerRadius = 18;
searchBar.layer.masksToBounds = YES;
[searchBar.layer setBorderWidth:8];
[searchBar.layer setBorderColor:[UIColor whiteColor].CGColor];
searchBar.placeholder = @"搜索内容";
[View addSubview:searchBar];
[self.navigationItem.titleView sizeToFit];
self.navigationItem.titleView = View;
网友评论