ModuleBundle

open class ModuleBundle : NSObject

业务模块Bundle基类,各模块可继承

资源查找规则如下:

  1. ModuleBundle基类或主应用模块类只加载主Bundle
  2. ModuleBundle子模块类优先加载主应用的{模块名称}.bundle(可替换模块),如主应用内FWFramework.bundle
  3. ModuleBundle子模块类其次加载该模块的{模块名称}.bundle,如框架内FWFramework.bundle
  4. ModuleBundle子模块类以上都不存在时返回nil加载主Bundle
  • 获取当前模块Bundle并缓存,initializeBundle为空时默认主Bundle

    Declaration

    Swift

    open class func bundle() -> Bundle
  • 获取当前模块图片

    Declaration

    Swift

    open class func imageNamed(_ name: String) -> UIImage?
  • 设置当前模块动态图片

    Declaration

    Swift

    open class func addImage(_ name: String, image: UIImage?)
  • 设置当前模块动态图片句柄

    Declaration

    Swift

    open class func addImage(_ name: String, block: (@Sendable () -> UIImage?)?)
  • 获取当前模块颜色,不存在时默认clear

    Declaration

    Swift

    open class func colorNamed(_ name: String) -> UIColor
  • 设置当前模块动态颜色

    Declaration

    Swift

    open class func addColor(_ name: String, color: UIColor?)
  • 设置当前模块动态颜色句柄

    Declaration

    Swift

    open class func addColor(_ name: String, block: (@Sendable () -> UIColor)?)
  • 获取当前模块多语言,可指定文件

    Declaration

    Swift

    open class func localizedString(_ key: String, table: String? = nil) -> String
  • 设置当前模块动态多语言

    Declaration

    Swift

    open class func addStrings(_ language: String? = nil, table: String? = nil, strings: [String : String])
  • 获取当前模块资源文件路径

    Declaration

    Swift

    open class func resourcePath(_ name: String, type: String? = nil) -> String?
  • 获取当前模块资源文件URL

    Declaration

    Swift

    open class func resourceURL(_ name: String, type: String? = nil) -> URL?

Override

  • 初始化模块Bundle,子类可重写,用于加载自定义Bundle

    Declaration

    Swift

    open class func initializeBundle() -> Bundle?
  • 初始化完成钩子,bundle方法自动调用一次,子类可重写,用于加载动态资源等

    Declaration

    Swift

    open class func didInitialize()