UITextField within UISearchBar in iOS 7

后端 未结 7 1667
北荒
北荒 2020-12-16 01:00

I am trying to accomplish the same look of my UISearchBar with a TextField within it, as in my iOS 6 app. I have tried to code it in several ways and not yet been successful

相关标签:
7条回答
  • 2020-12-16 01:31

    Swift solution

    for subView in searchBar.subviews{
            for deeperView in subView.subviews{
                if let searchField:UITextField = deeperView as? UITextField{
                    searchField.layer.borderWidth = 1.0
                    searchField.layer.borderColor = UIColor(red: 134/255, green: 14/255, blue: 75/255, alpha: 1).CGColor
                    searchField.layer.cornerRadius = 5.0
                }
            }
        }
    
    0 讨论(0)
提交回复
热议问题