swift Serach Bar定制

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Serach Bar定制相关的知识,希望对你有一定的参考价值。

extension UISearchBar {
    var textField: UITextField {
        guard let tf = (value(forKey: "searchField") as? UITextField) else { fatalError() }
        return tf
    }

    func addToolBar() {
        //Add done button to numeric pad keyboard
        let toolbarDone = UIToolbar.init()
        toolbarDone.sizeToFit()
        let flex = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace,
                                        target: self, action: nil)
        let barBtnDone = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonSystemItem.done,
                                              target: self, action: #selector(numDonePressed))

        toolbarDone.items = [flex, barBtnDone] // You can even add cancel button too
        self.inputAccessoryView = toolbarDone
    }

    @objc
    func numDonePressed() {
        self.resignFirstResponder()
    }
}

以上是关于swift Serach Bar定制的主要内容,如果未能解决你的问题,请参考以下文章

架构师成长记_第八周_08_ES-文档的基本操作

highcharts为X轴标签添加链接

Swift: case foo (let bar): 没有类型或赋值?

LeetCode Lowest Common Ancestor of a Binary Serach Tree

r 定制堆叠的#rt http://stackoverflow.com/questions/2578961/how-to-better-create-stacked-bar-graphs-with-m

二叉查找树 Binary Serach Tree