Search code examples
iosswiftswift2uitoolbar

Show UIToolBar in iOS


I have an UiToolbar, and I want to show it when tapped. I have used UITextBox, and when I tap inside this textbox, this UiToolbar is shows.

My Swift code is:

txf_provider.inputView = pickerProvider
txf_provider.inputAccessoryView = toolBar

Now, I want to tap to UILabel. It shows, but property of Label has only get method.


Solution

  • This worked for me. Let me know if this is what you were looking for:

    import UIKit
    
    class ViewController: UIViewController {
    
    var toolBar = UIToolbar(frame:CGRectMake(0, 524, 320, 44))
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            toolBar.barStyle = UIBarStyle.Black
           self.view.addSubview(toolBar)
    
    
        }
    }