测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布日期最后发布日期 | 2016年10月 |
SPM支持SPM | ✗ |
由Vivien Cormier维护。
在两种内容模式(UIViewContentModeScaleAspectFill / UIViewContentModeScaleAspectFit)之间创建UIImageView动画
我的网站 - My WebSite - 我的Twitter
兼容Swift 3.0
要观看演示视频,请点击此处
使用Pod(或者下载并将“UIImageViewModeScaleAspect.swift”添加到您的xcode项目中。)
pod 'UIImageViewModeScaleAspect'
初始化UIImageViewModeScaleAspect。重要!不要忘记初始化contentMode
let myImage = UIImageViewModeScaleAspect(frame: CGRect(x: 0, y: 100, width: 200, height: 100))
myImage.contentMode = .scaleAspectFill // Add the first contentMode
myImage.image = UIImage(named: "Octocat")
view.addSubview(myImage)
将UIViewContentModeScaleAspectFill转换为UIViewContentModeScaleAspectFit
myImage.animate( .fit, frame: CGRect(x: 0, y: 0, width: 200, height: 200), duration: 0.4)
将UIViewContentModeScaleAspectFit转换为UIViewContentModeScaleAspectFill
myImage.animate( .fill, frame: CGRect(x: 0, y: 0, width: 200, height: 200), duration: 0.4)
将UIViewContentModeScaleAspectFill转换为UIViewContentModeScaleAspectFit
myImage.initialeState(.fit, newFrame: CGRect(x: 0, y: 100, width: 200, height: 100))
UIView.animate(withDuration: 0,4, delay: 0, options: .allowAnimatedContent, animations: {
//
// Others Animation
//
myImage.transitionState(.fit)
}, completion: { (finished) in
myImage.endState(.fit)
})
将UIViewContentModeScaleAspectFit转换为UIViewContentModeScaleAspectFill
myImage.initialeState(.fill, newFrame: CGRect(x: 0, y: 100, width: 200, height: 100))
UIView.animate(withDuration: 0,4, delay: 0, options: .allowAnimatedContent, animations: {
//
// Others Animation
//
myImage.transitionState(.fill)
}, completion: { (finished) in
myImage.endState(.fill)
})