21 lines
462 B
Swift
21 lines
462 B
Swift
//
|
||
// UIImage+Resource.swift
|
||
// QuickLocation
|
||
//
|
||
|
||
import UIKit
|
||
|
||
extension UIImage {
|
||
|
||
/// 从 Resources 目录加载切图,兼容 Assets.xcassets
|
||
static func resource(_ name: String) -> UIImage? {
|
||
if let assetImg = UIImage(named: name) {
|
||
return assetImg
|
||
}
|
||
guard let path = Bundle.main.path(forResource: name, ofType: nil) else {
|
||
return nil
|
||
}
|
||
return UIImage(contentsOfFile: path)
|
||
}
|
||
}
|