代码如下
- (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; } }
时间: 2024-09-29 03:40:33