键盘动画效果流畅

时间:2020-05-19 22:34:54

标签: ios swift uiview

我正在关注代码。对于我的应用程序,0.03的延迟是一个神奇的数字,可以看到平滑滚动。对于其他任何值,它都不平滑。我想知道是否有确切的公式来计算延迟以使滚动平滑?

@objc func keyboardWillShow(notification: NSNotification) {

    self.topConstraints.constant = 16
    // this lags
    // let duration: TimeInterval = (notification.userInfo![UIResponder.keyboardAnimationDurationUserInfoKey])as! TimeInterval 

    UIView.animate(withDuration: 0, delay: 0.03, options: UIView.AnimationOptions.curveEaseOut, animations: {
        self.view.layoutIfNeeded()
    }, completion: { (completed) in
    })
}

0 个答案:

没有答案
相关问题