【发布时间】:2019-04-10 07:00:16
【问题描述】:
我正在尝试在我的 iOS 应用程序中为 UIImageView 实现一段时间的闪烁/闪烁效果。我希望 UIImageView 使用 alpha 闪烁/闪烁,而不是使用不同的图像。
我有另一个来自 android 应用程序的 code-sn-p,它描述了我试图在 XCode Swift 中实现的目标。我把它贴在下面:
这是我目前在 XCode Swift 中所取得的成就:
ellipses.alpha=0.8
ellipses.animationDuration=1
ellipses.animationRepeatCount=0
ellipses.startAnimating()
当然,它不起作用!我不太确定如何实现这一目标,并且很乐意获得一些指导。
以下代码适用于 android,不适用于 Swift/Xcode(但它描述了我的目标非常明确)
Animation animation = new AlphaAnimation(1, 0); //to change visibility from visible to invisible
animation.setDuration(1000); //1 second duration for each animation cycle
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE); //repeating indefinitely
animation.setRepeatMode(Animation.REVERSE); //animation will start from end point once ended.
imageButton.startAnimation(animation); //to start animation
【问题讨论】: