ViewTransformers 允许您将多个视图转换作为数组传递给 UIView。
通过 Cocoapods 安装
将以下内容添加到您的 Podfile
use_frameworks!
pod 'ViewTransformers'
如何使用
您可以通过使用 UIView 的 transforms
属性轻松地将多个视图转换传递给 UIView。
view.transforms = [
CGAffineTransform(scaleX: 0.5, y: 0.5),
CGAffineTransform(rotationAngle: -1.42),
CGAffineTransform(translationX: 100, y: -145)
]
仅读取 transforms 属性时,返回的是一个包含一个元素的数组中的 合并转换。
示例
示例中使用的代码
func playAnimation() {
UIView.animate(withDuration: 1.0, delay: 1.0, options: .curveLinear, animations: {
self.myView.transforms = [
CGAffineTransform(scaleX: 0.5, y: 0.5),
CGAffineTransform(rotationAngle: -1.42),
CGAffineTransform(translationX: 100, y: -145)
]
}, completion: { _ in
UIView.animate(withDuration: 1.0, delay: 1.0, options: .curveLinear, animations: {
self.myView.transforms = nil
}, completion: { _ in
self.playAnimation()
})
})
}
贡献
问题和悬停请求欢迎!