美文网首页
Swift 改变 UISearchBar PlaceHolder

Swift 改变 UISearchBar PlaceHolder

作者: 村口滕师傅 | 来源:发表于2017-05-07 11:55 被阅读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
            }
    

    相关文章

      网友评论

          本文标题:Swift 改变 UISearchBar PlaceHolder

          本文链接:https://www.haomeiwen.com/subject/mtyutxtx.html