TIMEX
TIMEX

Reputation: 272204

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

I know that there are multiple ways (CAAnimation, commitAnimations, etc), but what is the simplest way?

I'd like the UIView to start from blue and then fade to clear (or white, whatever is easier) in X milliseconds.

Upvotes: 5

Views: 2601

Answers (1)

brimstone
brimstone

Reputation: 3400

You can use UIView's animation method. It's much simpler than the other animations, but is more limited. Luckily, backgroundColor is one of the animatable ones. Example:

self.view.backgroundColor = UIColor.blueColor()

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

Upvotes: 11

Related Questions