FZTheme 0.1.0

FZTheme 0.1.0

FranZhou 维护。



FZTheme 0.1.0

  • FranZhou

FZTheme

CI Status Version License Platform

示例

要运行示例项目,请先克隆仓库,然后在 Example 目录下运行 pod install

需求

安装

FZTheme 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中即可

pod 'FZTheme'

说明

  1. 切换主题样式
FZThemeManager.manager.switchCurrentTheme(to: .dark)
  1. 注册主题加载器
FZThemeManager.manager.themeLoader { (style) -> (Bool, FZThemeMachineProtocol?)? in
            // true means it will cache themeMachine for the style
            // false means when style changed, it will enter here again
            return (true, DemoThemeMachine(themeStyle: style))
        }

3.绑定 UI 类似

self.view.fz_theme.appearance { (view, style, themeMachine) in
            switch style{
            case .light:
                view.backgroundColor = UIColor.white
            case .dark:
                view.backgroundColor = UIColor.red
            case .custom(let _):
                view.backgroundColor = UIColor.green
            }
        }

如果使用主题机,您可以像这样使用它

self.view.fz_theme.appearance { (view, style, themeMachine) in
            view.layer.contents = themeMachine?.themeImage(withIdentifier: "backgroundImage", themeStyle: style, defaultImage: nil)?.cgImage
        }
  1. 更多请看示例项目

作者

周帆,[email protected]

许可证

FZTheme遵循MIT许可证。有关更多信息,请参阅LICENSE文件。