Reputation: 251
I have code:
typealias animationBlock = () -> Void
func fade(withAnimation animations: animationBlock ) {
UIView.transition(with: blankView!, duration: TimeInterval(kAnimationDuration), options: .transitionCrossDissolve, animations: animations)
}
I tried a lot and can not what is wrong
Upvotes: 0
Views: 63
Reputation: 9819
When a closure parameter is optional, it becomes @escaping
, so mark your animations
parameter with @escaping
:
typealias animationBlock = () -> Void
func fade(withAnimation animations: @escaping animationBlock) {
UIView.transition(with: blankView!,
duration: TimeInterval(kAnimationDuration),
options: .transitionCrossDissolve,
animations: animations)
}
Upvotes: 1