Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animate objects in Swift?

In swift, I am transitioning an object in to the view, and I need it to slide in, or fade in. How can I obtain this type of animation in my program?

I have all my view elements made programmatically without IB (Interface Builder)

Is there documentation I can look at for reference? I could not find any.

like image 741
Benr783 Avatar asked Jun 08 '14 20:06

Benr783


1 Answers

I'm used to using [UIView animateWithDuration ...], but I found it a bit tricky switching the block syntax over to Swift at first. Here's a quick lazy code:

view.alpha = 0.0
UIView.animateWithDuration(0.25, animations: {
    view.alpha = 1.0
}, completion: {
    (value: Bool) in
    println(">>> Animation done.")
})
like image 110
LordParsley Avatar answered Oct 12 '22 23:10

LordParsley