swift3.0鍵盤彈起遮擋輸出框問題的處理方案。本站提示廣大學習愛好者:(swift3.0鍵盤彈起遮擋輸出框問題的處理方案)文章只能為提供參考,不一定能成為您想要的結果。以下是swift3.0鍵盤彈起遮擋輸出框問題的處理方案正文
上面一段代碼是給大家引見的swift3.0鍵盤彈起遮擋輸出框問題的處理方案代碼解析,詳細代碼如下所示;
extension LoginViewController:UITextFieldDelegate
{
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
//鍵盤發出,view放下
UIView.animate(withDuration: 0.4, animations: {
self.view.frame.origin.y = 0
})
return true
}
func textFieldDidBeginEditing(_ textView:UITextField) {
//view彈起跟隨鍵盤,高可依據自己定義
UIView.animate(withDuration: 0.4, animations: {
self.view.frame.origin.y = -150
})
}
}
好了,代碼到此完畢,希望對大家有所協助!