Sha256: 30c81e33dd5c624d20cdf901f9dbbc70d1b60a51e9bde6d9b39af9a3530c8c64

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

//
//  <%= @prefixed_module %>Tool.swift
//  <%= @project %>
//
//  Created by <%= @author %> on <%= @date %>.
//

import UIKit

@objc
open class <%= @prefixed_module %>Tool: NSObject {
    static let kModuleName = "<%= @project %>"
    
    private class func kResourceBundlePath() -> String? {
        let bundlePath: String? = kModuleBundle().path(forResource: kModuleName, ofType: "bundle")
        if bundlePath == nil { //bundle 不存在
            print("\nPOD_NAME xcassets bundle not exist:\(kModuleName)\n")
        }
        return bundlePath
    }
    
    /// 组件bundle
   @objc public class func kModuleBundle() -> Bundle{
        let result = Bundle.init(for: <%= @prefixed_module %>Tool.self)
        return result
    }
    
    /// 组件 素材bundle
    @objc public class func kModuleResourceBundle() -> Bundle {
        let path: String? = self.kResourceBundlePath()
        var result = Bundle.main
        if path != nil {
            result = Bundle.init(path: path!)!
            if result.isLoaded == false {
                do {
                    try result.loadAndReturnError()
                }
                catch {
                    
                }
            }
        }
        
        return result
    }
    
    ///资源组件 获取xcasserts 中图片
   @objc public class func kResourceImage(name: String?) -> UIImage? {
       let imgName = name ?? ""
       let result = UIImage.init(named: imgName, in: kModuleResourceBundle(), compatibleWith: nil)
       return result
    }
}

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ykioscmd-0.6.7 lib/yk_command/module/template/swift/Tool.swift
ykioscmd-0.6.6 lib/yk_command/module/template/swift/Tool.swift
yk_command-0.6.5 lib/yk_command/module/template/swift/Tool.swift
yk_command-0.6.4 lib/yk_command/module/template/swift/Tool.swift