我尝试将UIRefreshControl
和UISearchController
放入UITableView
。
当我下拉到refresh
时效果很好,但首先加载UIRefreshControl is covered by the UISearchController
:
这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
self.refreshControl = UIRefreshControl()
self.refreshControl?.backgroundColor=UIColor.clearColor()
self.refreshControl!.addTarget(self, action: #selector(SocialManTableViewController.refresh(_:)), forControlEvents: UIControlEvents.ValueChanged)
self.refreshControl!.tintColor = UIColor(colorLiteralRed: 59/255, green: 89/255, blue: 152/255, alpha: 1)
self.refreshControl!.beginRefreshing()
searchController = UISearchController(searchResultsController: nil)
searchController.searchBar.sizeToFit()
searchController.searchBar.barTintColor = UIColor.clearColor()
searchController.searchBar.backgroundImage = UIImage()
searchController.searchBar.tintColor=UIColor.blackColor()
tableView.setContentOffset(CGPoint(x: 0, y: searchController.searchBar.frame.size.height), animated: false)
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
}