What is the iPhone's default keyboard animation rate?

前端 未结 7 1896
萌比男神i
萌比男神i 2020-12-13 13:21

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.

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 13:54

    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)
    

提交回复
热议问题