Light gray background in “bounce area” of a UITableView

前端 未结 16 2108
一整个雨季
一整个雨季 2020-11-28 23:05

Apple\'s iPhone apps such as Music and Contants use a search bar in a UITableView. When you scroll down so that the search bar moves down, the empty space above the scroll v

16条回答
  •  醉话见心
    2020-11-28 23:20

    I will give you the best way to do this.
    First set the background color of the table view to the one you want in interface builder.
    Then respond to the UITableView delegate tableView:willDisplayCell:ForIndexPath: method like this

    - (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCelll*)cell forIndexPath:(NSINdexPath*)indexPath
    {
         [cell setBackgroundColor:[UIColor whiteColor]];
    }
    


    Another Method is :
    in ViewDidLoad method (or anywhere you like) set the tableView background color to clear color like this:

    self.tableView.backgroundColor = [UIColor clearColor];
    

    and then set the superview color to white

    self.tableView.superview.backgroundColor = [UIColor whiteColor];
    

提交回复
热议问题