我正在关注代码。对于我的应用程序,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
})
}