实现我的 Tab、对齐 Android 流程并接入 OSS 上传
This commit is contained in:
20
suixinkan/UI/Common/UIImageView+Remote.swift
Normal file
20
suixinkan/UI/Common/UIImageView+Remote.swift
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user