繁体   English   中英

迅速在Apple Watch / Watchkit中几秒钟后为视图设置Alpha的更好方法

[英]better way to set alpha for a view after a few seconds in apple watch / watchkit in swift

我正在尝试将带有动画的alpha设置为Apple Watch应用程序中的图像视图。

为此,我尝试了下面的代码

UIView.animateWithDuration(1.5, animations: {
        self.splashscreenImage.alpha = 1.0
        return
   })

但是它的错误

  'WKInterfaceImage' does not have a member named 'alpha'

所以我在willActivate函数中实现了下面的代码

var timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector("splashscreenAlpha"), userInfo: nil, repeats: false)

func splashscreenAlpha() {
   self.splashscreenImage.setAlpha(0.0)
}

但是在这种情况下,视图就像是不可见的,就像图像视图具有黑色背景。 但是我希望动画消失。 我怎样才能做到这一点?

你应该尝试使用

UIView.animateWithDuration(1.5, animations: { self.splashscreenImage.setAlpha(1.0) return })

制作alpha动画。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM