A UIImageView that allows for animations between UIViewContentModes through the use of UIView block-based animations e.g. UIView.animateWithDuration…
使用 Swift 在 iOS8 和 iOS9 上进行了测试
let imageView = INSImageView(...)
imageView.contentMode = .ScaleAspectFit
UIView.animateWithDuration(1,
animations: {
self.imageView.contentMode = .ScaleAspectFill
}
)
由于 INSImageView 的实现方式,需要将 image
和 highlightedImage
属性获取器设置为 NOOP。如果您希望获取原始图片,请分别使用 originalImage
或 originalHighlightedImage
。
let image = imageView.originalImage
let highlightedImage = imageView.originalHighlightedImage
INSImageView 可通过 CocoaPods 获取。要安装它,只需将以下行添加到 Podfile
pod "INSImageView"
Patrick, [email protected]
INSImageView 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。