简体   繁体   中英

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

I am trying to set alpha with animation to image view in swift for apple watch application.

to do that i have tried code below

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

but its iving error as

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

so i implemented code below in willActivate function

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

and

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

but in this scenario, view is like invisible, like image view has a black background. But i would like it to gone with animation. How can i do that?

You should try using

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

to make alpha animation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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