首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >iOS 13替代“setAnimationCurve”

iOS 13替代“setAnimationCurve”
EN

Stack Overflow用户
提问于 2019-10-25 15:48:09
回答 1查看 2.4K关注 0票数 3

随着iOS 13,苹果,放弃了的许多功能,我一直在我的应用程序。对他们中的大多数人来说,StackOverflow已经给出了很好的解释--但是对于StackOverflow来说并非如此。

'setAnimationCurve'

13.0中被废弃:使用基于块的动画API代替

,这是我的确切代码:

代码语言:javascript
运行
复制
  // 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()

                }

            }



        }

    }

}

当键盘出现时,我使用这段代码在屏幕底部的一个条形图上/下滑动。

我真的很感谢在这个话题上的任何帮助.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-25 15:53:21

如果您想要内置动画曲线,请调用

代码语言:javascript
运行
复制
animate(withDuration:delay:options:animations:completion:)

options:允许您包含一个动画曲线。

但更好的选择是根本不使用UIView类动画调用。使用UIViewPropertyAnimator。现在你可以应用任何你喜欢的动画曲线。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58561810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档