我如何在 Swift 3 中做一个简单的完成 block ?
我想在动画完成时设置self.isOpen = true
:
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)
顺带一提:
由于互联网上什么都没有,所以学习 Swift 3 atm 几乎是不可能的:(
我还搜索了整个文档,甚至没有提到“动画”一词,但找不到任何内容:
最佳答案
你这样添加:
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
})
关于ios - UIView.animate - Swift 3 - 完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39682128/