gpt4 book ai didi

ios - Swift 动画重复次数

转载 作者:搜寻专家 更新时间:2023-10-31 08:13:06 28 4
gpt4 key购买 nike

我有以下代码想要淡入和淡出 UILabel。但我只想让它重复淡入淡出 5 次。我的问题是如何设置动画只重复 3 次?

func savingIcon(){
Loading.hidden=false
UIView.animateWithDuration(1.0,
delay: 0.0,
options: [ .CurveEaseInOut],
animations: {

self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;

},
completion: { finished in
print("Save done")

self.Loading.hidden=true


})

}

最佳答案

如果你想重复你的动画 block 5 次,尝试这样做:

UIView.animateWithDuration(1.0,
delay: 0.5,
options: [ .CurveEaseInOut, .Repeat],
animations: {

UIView.setAnimationRepeatCount(5)

self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;

},
completion: { finished in
print("Save done")

self.Loading.hidden=true


})

关于ios - Swift 动画重复次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38313101/

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