Mike Mclaren
Mike Mclaren

Reputation: 251

Cannot convert value of type and my problem

I have code:

typealias animationBlock = () -> Void

func fade(withAnimation animations: animationBlock ) {
    UIView.transition(with: blankView!, duration: TimeInterval(kAnimationDuration), options: .transitionCrossDissolve, animations: animations)
  }


enter image description here


I tried a lot and can not what is wrong

Upvotes: 0

Views: 63

Answers (1)

TylerP
TylerP

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

Related Questions