Remove Border of UISearchBar in iOS7

前端 未结 10 1672
死守一世寂寞
死守一世寂寞 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:11

    Okay. There are so many answers, but they are too complex. I've found this solution:

    Swift 3 (4)

    searchBar.setBackgroundImage(UIImage(), for: .top, barMetrics: .default)
    searchBar.backgroundColor = .primary
    

    Where .primary is

    extension UIColor {
    
        static var primary:UIColor {
            return "#5163F4".color
        }
    }
    

提交回复
热议问题