How can I make a UIView fade from a solid background color to clear the background color?

I know that there are several ways (CAAnimation, commitAnimations, etc.), but what is the easiest way?

I want the UIView to start with blue and then fade out to clear (or white, which is easier) in X milliseconds.

+4
source share
1 answer

You can use the animation method UIView. This is much simpler than other animations, but more limited. Fortunately, it backgroundColoris one of the animated ones. Example:

self.view.backgroundColor = UIColor.blueColor()

UIView.animateWithDuration(1.0, animations: {
    self.view.backgroundColor = UIColor.clearColor()
})
+7
source

All Articles