我正在尝试为 UIImageView 做一些动画(仅缩小)
1-我将框架设置为大于屏幕以使其放大,如下所示:
private lazy var imageView: UIImageView = {
let image = UIImageView()
image.frame = CGRect(x: 0, y: 0, width: view.frame.width + 300, height: view.frame.height + 300)
image.center = view.center
image.image = UIImage(named: "1111")
image.contentMode = .scaleAspectFill
return image
}()
Run Code Online (Sandbox Code Playgroud)
我想让框架回到屏幕尺寸,如下所示:
func firstAnimation() {
UIView.animate(withDuration: 15, animations: {
// HERE
self.imageView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
}) { (finished) in
self.secondAnimation()
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是我没有和我一起工作。
这里是完整的类代码: github
用于CGAffineTransform.identity将图像大小调整为第一个identity
UIView.animate(withDuration: 0.5, delay: 0.0, options: UIViewAnimationOptions.curveEaseIn, animations: {
// HERE
self.imageview.transform = CGAffineTransform.identity.scaledBy(x: 2, y: 2) // Scale your image
}) { (finished) in
UIView.animate(withDuration: 1, animations: {
self.imageview.transform = CGAffineTransform.identity // undo in 1 seconds
})
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7668 次 |
| 最近记录: |