// 在iOS11 之后适配titleView
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame =CGRectMake(0, 0, kScreenWidth, 44);
self.navigationItem.titleView = button;
_searchBar = [[UISearchBar alloc] initWithBackgroundImage:nil placeholder:@"搜一搜,订单一清二楚" isFollow:YES];
_searchBar.delegate = self;
if (@available(iOS 11.0, *)) {
// https://www.jianshu.com/p/352f101d6df1
// 下面的 100 可以根据情况添加
_searchBar.frame = CGRectMake(0, 0, kScreenWidth - 100, button.height);
}
[button addSubview:_searchBar];