随着iOS 13,苹果,放弃了的许多功能,我一直在我的应用程序。对他们中的大多数人来说,StackOverflow已经给出了很好的解释--但是对于StackOverflow来说并非如此。
'setAnimationCurve'在
13.0中被废弃:使用基于块的动画API代替
,这是我的确切代码:
// MARK: - Keyboard up/down adjustment for the addMediaBar
@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
let userInfo = notification.userInfo! as [AnyHashable: Any]
let animationDuration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! NSNumber
let animationCurve = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! NSNumber
if addMediaBarBottomAnchor.constant == 0 {
let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
if let bottomPadding = window?.safeAreaInsets.bottom {
print(keyboardSize.height)
print(bottomPadding)
UIView.setAnimationCurve(UIView.AnimationCurve(rawValue: animationCurve.intValue)!)
UIView.animate(withDuration: animationDuration.doubleValue) {
self.addMediaBarBottomAnchor.constant = -keyboardSize.height + bottomPadding
self.view.layoutIfNeeded()
}
} else {
UIView.setAnimationCurve(UIView.AnimationCurve(rawValue: animationCurve.intValue)!)
UIView.animate(withDuration: animationDuration.doubleValue) {
self.addMediaBarBottomAnchor.constant = -keyboardSize.height
self.view.layoutIfNeeded()
}
}
}
}
}
当键盘出现时,我使用这段代码在屏幕底部的一个条形图上/下滑动。
我真的很感谢在这个话题上的任何帮助.
发布于 2019-10-25 15:53:21
如果您想要内置动画曲线,请调用
animate(withDuration:delay:options:animations:completion:)
options:
允许您包含一个动画曲线。
但更好的选择是根本不使用UIView类动画调用。使用UIViewPropertyAnimator。现在你可以应用任何你喜欢的动画曲线。
https://stackoverflow.com/questions/58561810
复制相似问题