JLChen
2021-05-18 a869383e163a18cdedcf587383c1eca043129754
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
//  Copyright © 2020 dahua. All rights reserved.
//
 
import Foundation
 
extension Bundle {
    
    static var bundle: Bundle? = nil
    
    class func dh_addDeviceBundle() -> Bundle? {
 
        if self.bundle == nil, let path = Bundle(for: LCAddDeviceModule.classForCoder()).path(forResource: "LCAddDeviceModuleBundle", ofType: "bundle") {
            self.bundle = Bundle(path: path)
        }
        
        return self.bundle
    }
    
    
    
    // 获取app当前版本
    class func appVersion() -> String {
        var versionString = ""
        guard let dict = main.infoDictionary else {
            return versionString
        }
        
        if  dict["CFBundleShortVersionString"] is String {
            versionString = dict["CFBundleShortVersionString"] as! String
        }
        
        return versionString
    }
}
 
// MARK: UIImage扩展,内部使用。
extension UIImage {
    
    /// 加载当前Bundle的图片
    ///
    /// - Parameter named: 图片名称
    convenience init?(dh_bundle bundle: Bundle? = Bundle.dh_addDeviceBundle(), dh_named named: String) {
        self.init(named: named, in: bundle, compatibleWith: nil)
    }
}