//
Viewcontroller.swift
Uitextfield How to turn off the keyboard after completing the input
//
Created by Yue technology on 15/1/19.
Copyright (c) year BSY. All rights reserved.
//
Import UIKit
Class Viewcontroller:uiviewcontroller,uitextfielddelegate {
var TEXTF = Uitextfield ()
Override Func Viewdidload () {
Super.viewdidload ()
[Self. Adduitextfield ()];
}
Func Adduitextfield () {
var Text:uitextfield = Uitextfield (Frame:cgrectmake (30, 100, 260, 30))
Text.layer.borderColor = Uicolor. Lightgraycolor (). Cgcolor
Text.layer.borderWidth = 2
Self.view.addSubview (text)
Text.delegate = Self
SELF.TEXTF = text
}
/**
The first method of fallback keyboard
*/
Override Func Touchesbegan (Touches:nsset, withevent event:uievent) {
Self.textF.resignFirstResponder ()
// }
/**
The second method of fallback keyboard
*/
Func Textfieldshouldreturn (Textfield:uitextfield), Bool {
if (Self.textf==textfield) {
Textfield.resignfirstresponder ()
}
return True
}
}
IOS Uitextfield Summary of how to turn off the keyboard after completing the input