No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Blog_UIViewAnimationSyntaxSugar.playground
.gitignore
LICENSE
README.md
UIView+Animator.swift

README.md

Swift: UIView Animation Syntax Sugar

Because closures make ugly couples

If you hadn’t already heard, closures are a great tool to utilise in your Swift code. They’re first-class citizens, they can become trailing closures if they’re at the end of an API and now they’re @noescape by default which is a massive win in the fight against reference cycles. But every once in a while we have to work with APIs that contain more than one closure, which turns this beautiful language feature into something far less appealing. I’m looking at you, UIView.

Read the full article here

--

###tl;dr ####Turn this

UIView.animate(withDuration: 0.4, animations: {
    view.frame.size.height = 100
    view.frame.size.width = 100
}) { finished in
    view.backgroundColor = .black
}

####Into this

UIView.Animator(duration: 0.3)
    .animations {
        view.frame.size.height = 100
        view.frame.size.width = 100
    }
    .completion { finished in
        view.backgroundColor = .black
    }
    .animate()