Skip to content

Instantly share code, notes, and snippets.

@Monntay
Created May 5, 2020 14:22
Show Gist options
  • Select an option

  • Save Monntay/962b22fa71d998df255703d49fee6a44 to your computer and use it in GitHub Desktop.

Select an option

Save Monntay/962b22fa71d998df255703d49fee6a44 to your computer and use it in GitHub Desktop.
import UIKit
import RxCocoa
import RxSwift
extension Reactive where Base: UIImageView {
func image(withDuration: TimeInterval) -> Binder<UIImage?> {
return Binder(base) { imageView, image in
// needed to avoid "Value of type 'UIView' has no member 'image'"
let baseImageView = imageView
UIView.transition(with: imageView,
duration: withDuration,
options: .transitionCrossDissolve,
animations: { baseImageView.image = image },
completion: nil)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment