与UISearchBar的stange行为UIRefreshControl

时间:2014-12-16 19:02:43

标签: ios uitableview uisearchbar uirefreshcontrol

我正在使用UIRefreshControl和UISearchBar当我拉动刷新时,我看到uiviewcontroller顶部的白色背景

   UISearchBar *searchBar =
[[UISearchBar alloc] initWithFrame:
 CGRectMake(0, 0, self.tableView.frame.size.width, 44.0)];
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
self.tableView.tableHeaderView = searchBar;

 _refreshControl = [[UIRefreshControl alloc] init];
[_refreshControl addTarget:self action:@selector(update) forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:_refreshControl];

enter image description here

enter image description here

问题是上面的白色背景

任何想法?

1 个答案:

答案 0 :(得分:5)

为表格创建背景视图并将其颜色设置为clearColor,如此

- (void)viewDidLoad {
    self.tableView.backgroundView = [UIView new];
    self.tableView.backgroundView.backgroundColor = [UIColor clearColor];
}