Skip to content

Instantly share code, notes, and snippets.

@beyzaince
Created November 23, 2021 17:19
Show Gist options
  • Select an option

  • Save beyzaince/1670f210faca03c980b97f861719b971 to your computer and use it in GitHub Desktop.

Select an option

Save beyzaince/1670f210faca03c980b97f861719b971 to your computer and use it in GitHub Desktop.
public extension UIImageView {
static func swizzleSetImageWithUrl() {
guard let setImageWithMethod = class_getInstanceMethod(UIImageView.self, #selector(setImageWith(path:placeholder:completion:))),
let swizzledMethod = class_getInstanceMethod(UIImageView.self, #selector(setStaticImage)) else { return }
method_exchangeImplementations(setImageWithMethod, swizzledMethod)
}
@objc private func setStaticImage() {
sd_setImage(with: URL(string: ""), placeholderImage: UIImage(named: "mock_snapshot_image"), completed: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment