func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
NSLog("将要开始编码")
var offset : CGFloat = CGFloat(self.view.frame.size.height) - CGFloat(self.txt_phone.frame.origin.y) - CGFloat(self.txt_phone.frame.size.height) - 216 - 50
if(offset <= 0)
{
UIView.animateWithDuration(0.3, animations: {
var frame : CGRect = self.view.frame
frame.origin.y = offset
self.view.frame = frame
})
}
return true
}
func textFieldDidEndEditing(textField: UITextField) {
UIView.animateWithDuration(0.3, animations: {
var frame : CGRect = self.view.frame
frame.origin.y = 0
self.view.frame = frame
})
}
Swift 文本编辑时将文本框上移
最新推荐文章于 2024-05-02 19:24:42 发布