簡體   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