【发布时间】:2020-02-22 00:00:39
【问题描述】:
在 iOS 13 中,Apple 弃用我在我的应用中使用的许多功能。对于他们中的大多数人来说,StackOverflow 上已经有很好地解释了替代方案 - 但不是'setAnimationCurve'。
'setAnimationCurve' 在 iOS 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()
}
}
}
}
}
每当键盘出现时,我正在使用此代码在屏幕底部向上/向下滑动一个条。
我将非常感谢有关此主题的任何帮助。
【问题讨论】:
标签: ios swift uikit ios13 ios-animations