What is the iPhone's default keyboard animatio

2019-01-22 01:43发布

A while ago I remember seeing a constant of some kind that defined the animation rate of the Keyboard on the iPhone and I can not for the life of me remember where I saw it....any insight?

7条回答
老娘就宠你
2楼-- · 2019-01-22 02:39

In Swift your code will look like this:

let keyboardSize: CGSize = userInfo[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue.size

let animationDuration = ((userInfo[UIKeyboardAnimationDurationUserInfoKey]) as! NSNumber).floatValue
let animationOptions = ((userInfo[UIKeyboardAnimationCurveUserInfoKey]) as! NSNumber).unsignedLongValue

UIView.animateWithDuration(NSTimeInterval(animationDuration), delay: 0,
  options: UIViewAnimationOptions(rawValue: animationOptions),
  animations: { () -> Void in
                self.view.frame.origin.y += keyboardSize.height
                }, 
  completion: nil)
查看更多
登录 后发表回答