代碼如下
- (void)viewDidLoad {
[super viewDidLoad];
UISearchBar * searchBar =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
self.tableView.tableHeaderView=searchBar;
self.searchController =[[UISearchDisplayController alloc]initWithSearchBar:searchBar contentsController:self];
//
//(refreshing)
//
[self.tableView setContentInset:UIEdgeInsetsMake(128, 0, 0, 0)];
}
問題如圖:
問題:searchBar的視圖中clipsToBounds 爲yes
解決方法:自定義searchbar,重寫layoutSubviews方法,把searchbar的所有subview的clipsToBounds重置爲no
-(void)layoutSubviews{
[super layoutSubviews];
for (UIView * view in self.subviews) {
view.clipsToBounds=NO;
}
}