Can some help me with the syntax of the transitionWithView in swift. in objective-c I would use it like so:
[UIView transitionWithView:[ self view ] duration:0.325 options:UIViewAnimationOptionCurveEaseOut animations:
^{
// do the transition
}
completion:
^( BOOL finished ){
// cleanup after the transition
}];
However I can not get the completion handler to work. thanks
Swift 3
the docs are a little tricky to find, but this should work:
You could use a trailing closure if you wanted for the
completion
handler, but I wouldn't in this case, it would be too messy/unclear.But if you weren't going to pass an animations block, it would be borderline readable:
it would be like this in Swift:
I'd like to add to the accepted answer that you can pass multiple options into
transitionWithView
by passing an array like so:Swift 2.0
Swift 1.2
and of course you can use the fully qualified syntax like this as well: