Remove Border of UISearchBar in iOS7

前端 未结 10 1654
死守一世寂寞
死守一世寂寞 2020-12-24 10:46

I\'m trying to remove border of UISearchBar in iOS 7. In iOS 6 it\'s working fine. I created the UISearchBar programatically. I tried almost every thing from Stack Overflow

10条回答
  •  温柔的废话
    2020-12-24 11:03

    Swift 2.1 in Xcode 7.2, this worked for me.

    self.searchController.searchBar.backgroundImage = UIImage()
    

    My full code below.

    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    self.searchController.searchBar.sizeToFit() 
    tableView.sectionIndexBackgroundColor = UIColor(red: 0/255, green: 181/255, blue: 229/255, alpha: 1.0)
    self.searchController.searchBar.backgroundColor = UIColor(red: 0/255, green: 181/255, blue: 229/255, alpha: 1.0)
    self.searchController.searchBar.barTintColor = UIColor(red: 0/255, green: 181/255, blue: 229/255, alpha: 1.0)
    self.searchController.searchBar.backgroundImage = UIImage()
    definesPresentationContext = true
    tableView.tableHeaderView = searchController.searchBar
    

提交回复
热议问题