UIView.animate - Swift 3 - 完成
如何在Swift 3中做一个简单的完成块?UIView.animate - Swift 3 - 完成
我想设置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)
在传:
这是非常不可能的学习斯威夫特3个大气压,由于互联网上的工作NOTHING :(
我也搜遍了整个文件,甚至提到单词 “动画”,但没有找到任何东西:
你加入这样的:
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
})
感谢一堆!他们的“建议”太神秘了,无法理解实际上写什么...以及缺少文档,以及压倒性数量的非工作swift2.2-代码是相当令人沮丧的:( –
动画是伟大的,但我怎么能相同按钮单击时按下布局? – pmb
写类似下面的代码:
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
// code
})
此答案不包含完成块,这是问题的要求。 – frakman1
对于未来:后自动生成.animate(...)函数,双击蓝色突出显示的((Bool) - > Void)?编辑器占位符和匿名块的结构将准备:) – Muli