Files
suixinkan_uikit/suixinkan/UI/Common/UIImageView+Remote.swift

21 lines
577 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// UIImageView+Remote.swift
// suixinkan
//
import Kingfisher
import UIKit
extension UIImageView {
/// URL
func loadRemoteImage(urlString: String?, placeholderColor: UIColor = UIColor(hex: 0xEFF6FF)) {
backgroundColor = placeholderColor
let trimmed = urlString?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
guard let url = URL(string: trimmed), !trimmed.isEmpty else {
image = nil
return
}
kf.setImage(with: url, placeholder: nil)
}
}