gpt4 book ai didi

ios - 向 animateKeyframes 添加缓动

转载 作者:行者123 更新时间:2023-11-28 09:26:09 24 4
gpt4 key购买 nike

我使用以下代码在 Swift 3 中使用 animateKeyframes 为按钮的比例设置动画:

UIView.animateKeyframes(withDuration: 4, delay: 1, options: [.repeat, .allowUserInteraction, .calculationModeCubic], animations: {
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.1, animations: {
self.myButton.transform = CGAffineTransform(scaleX: 1,y: 1)
})
UIView.addKeyframe(withRelativeStartTime: 0.1, relativeDuration: 0.1, animations: {
self.myButton.transform = CGAffineTransform(scaleX: 0.9,y: 0.9)
})
}, completion: nil)

我需要做的是为每个关键帧添加缓动。我查找了一些使用以下代码的东西,然后可以将其传递给 animateKeyframes

let animationOptions: UIViewAnimationOptions = .curveEaseIn
let keyframeAnimationOptions: UIViewKeyframeAnimationOptions = UIViewKeyframeAnimationOptions(rawValue: animationOptions.rawValue)

但是,它并没有完全说明如何传递 keyframeAnimationOptions 变量,我自己似乎也想不通!有人可以帮忙吗?

最佳答案

您可以使用以下代码调用 keyframeAnimationOptions 变量。

let keyframeAnimationOption=UIViewKeyframeAnimationOptions.CalculationModeCubic

UIView.animateKeyframesWithDuration(duration, delay: delay, options: keyframeAnimationOption, animations:
{
/////Your code //////

}, completion: nil)

关于ios - 向 animateKeyframes 添加缓动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40020415/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com