swift - Swift UIImage Animation - 从框架外飞入框架
问题描述
我目前正在尝试查看是否有任何教程或一些关于如何动画 UIImages 从框架外飞入框架的参考。我目前正在尝试使用底部代码,但它没有产生我想要的。
我正在创建一个 DC Universe 介绍页面,其中主要角色将一次飞入其中,并形成一个很好的角色集合,我认为这将非常酷。
UIView.animate(withDuration: 0.5, animations: {
self.superManImage.frame.origin.x -= 200 }, completion: nil)
解决方案
到目前为止,这对我有用。蝙蝠侠图像从顶部飞入,超人图像从左侧飞入。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
superManImage.center.x -= view.bounds.width
batManImage.center.y -= view.bounds.width
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 0.8, delay: 1.0, options: [], animations: {
self.superManImage.center.x += self.view.bounds.width
}, completion: nil)
UIView.animate(withDuration: 0.5, delay: 0.3, options: [], animations: {
self.batManImage.center.y += self.view.bounds.width
}, completion: nil)
}
推荐阅读
- ruby-on-rails - Ruby on Rails Forms has_many 与来自其他模型的动态数据
- android - 多次调用 onBackPressed 的 popBackStack 结果
- python - Unix:为什么我需要先关闭程序的输入 FIFO,然后才能从其输出 FIFO 中读取
- database - liquibase.exception.DatabaseException:错误:关系“容器”已经存在
- c - 如何在 OpenCL 中创建动态数组?
- javascript - Cordova App 创建目录
- model - 为什么我的模型对象在 dotnet core 2.x Razor 页面应用程序中的 Razor 页面上始终为空?
- mysql - 已将握手入队后无法将握手入队。使用 http 客户端和服务器获取数据
- javascript - D3.js 树 - 文本没有出现在节点内部、Firefox 或边缘
- windows - 在另一个命令行中将批处理命令行设置为字符串