Answers for "swift text with on keyboard"

1

How to set back button text in Swift

let backButton = UIBarButtonItem()

backButton.title = "name"

self.navigationController?.navigationBar.topItem?.backBarButtonItem = backButton
Posted by: Guest on December-18-2019
0

Close iOS Keyboard by touching anywhere using Swift

// Put this piece of code anywhere you like
extension UIViewController {
    func hideKeyboardWhenTappedAround() {
        let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
        tap.cancelsTouchesInView = false            
        view.addGestureRecognizer(tap)
    }

    @objc func dismissKeyboard() {
        view.endEditing(true)
    }
}

//Now in every UIViewController, all you have to do is call this function:

override func viewDidLoad() {
    super.viewDidLoad()
    self.hideKeyboardWhenTappedAround() 
}
Posted by: Guest on February-01-2020

Code answers related to "swift text with on keyboard"

Code answers related to "Swift"

Browse Popular Code Answers by Language