How do I do a simple completion block in Swift 3?
I want to set self.isOpen = true
in the completion 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)
In passing:
It's pretty impossible to learn Swift 3 atm due to NOTHING on the internet working :(
I've also searched this entire document for even a mention of the word "animate" and could not find anything:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097-CH3-ID0
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 })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With