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 }) }