ios - How do I call animateAlongsideTransition in Swift? -
i've tried many combinations in order call animatealongsidetransition
in swift transition coordinator. feel i'm missing stupid.
if want call (from swift docs):
func animatealongsidetransition(_ animation: ((uiviewcontrollertransitioncoordinatorcontext!) -> void)!, completion completion: ((uiviewcontrollertransitioncoordinatorcontext!) -> void)!) -> bool
how it? want pass things in animation block , nothing in completion block.
this want do:
coordinator.animatealongsidetransition({ context in // whatever context context.viewcontrollerforkey(uitransitioncontextfromviewcontrollerkey) }, completion: nil)
you can omit parameters if use variables $0
first implicit parameter , so
coordinator.animatealongsidetransition({ $0.viewcontrollerforkey(uitransitioncontextfromviewcontrollerkey) }, completion: nil)
the in
syntax surprises @ first, have learn once :)
- the curly brackets defines block inside function
- you use
in
separate parameters block body - but said above, can omit parameters using
$0
,$1
,$2
, so...
it seems there's more verbose syntax, not fits swift spirit (and i'm lazy post there)
hope helps (and don't forget anything...)
edit:
another pro tip when block parameter, can omit parentheses
(the next not work, it's figure idea)
coordinator.animatealongsidetransition{ $0.viewcontrollerforkey(uitransitioncontextfromviewcontrollerkey) }
Comments
Post a Comment