ios - UIView.animate - Swift 3 - 完成

标签 ios swift3 uiviewanimation

我如何在 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 几乎是不可能的:(


我还搜索了整个文档,甚至没有提到“动画”一词,但找不到任何内容:

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

最佳答案

你这样添加:

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/

相关文章:

ios - 快速将实例作为对另一个类的引用传递

ios - 如何从 UIWebView 中的 Base64 字符串加载 PDF

http - 如何在 Swift 3 中同时发出 https 请求

ios - 结束 UIView 动画时将 View 返回到原始位置

iOS UIView 动画取消不起作用

ios - 如何制作 uibutton zoomout 然后 crossblur?

iOS 强制 GCM 刷新注册 token

ios - 如何从 3rd 方 node.js 服务器验证游戏中心用户

ios - 为什么不允许我的团队管理 iCloud 容器?

iOS/macOS 应用内购买 - 在 KeyChain 中保存什么