Swift 改变 UISearchBar PlaceHolder

2017-05-07  本文已影响59人  村口滕师傅

简单的说,就是获取 UISearchBar 中的 UITextField,修改 UITextField 就变的简单很多。

if let textfield = searchbar.subviews.first?.subviews.last as? UITextField {
            textfield.attributedPlaceholder = NSAttributedString(string: "搜索", attributes: [NSForegroundColorAttributeName:UIColor.white])
            textfield.textColor = UIColor.white
        }
上一篇下一篇

猜你喜欢

热点阅读