UIView.animate - Swift 3 - completion

How to make a simple completion block in Swift 3?

I want to set self.isOpen = true at the end of the animation:

  UIView.animate(withDuration: 0.25, delay: 0.0, options: [], animations: { self.isOpen = true self.drawerView?.frame = CGRect(x: 0, y: 0, width: (self.drawerView?.frame.size.width)!, height: (self.drawerView?.frame.size.height)!) self.contentView?.frame = CGRect(x: 200, y: 0, width: (self.contentView?.frame.size.width)!, height: (self.contentView?.frame.size.height)!) }, completion: nil) 

Passing:

It's pretty impossible to recognize Swift 3 atm due to NOTHING on the internet working :(


I also searched this entire document even for the mention of the word β€œrevive” and found nothing:

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097-CH3-ID0

+8
ios swift3 uiviewanimation
source share
2 answers

You add it like this:

 UIView.animate(withDuration: 0.25, delay: 0.0, options: [], animations: { self.drawerView?.frame = CGRect(x: 0, y: 0, width: (self.drawerView?.frame.size.width)!, height: (self.drawerView?.frame.size.height)!) self.contentView?.frame = CGRect(x: 200, y: 0, width: (self.contentView?.frame.size.width)!, height: (self.contentView?.frame.size.height)!) }, completion: { (finished: Bool) in self.isOpen = true }) 
+49
source share

Write it down as shown below:

 UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: { // code }) 
-2
source share

All Articles