FranZhou / FZTheme

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FZTheme

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

FZTheme is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FZTheme'

instructions

  1. switch theme style:
FZThemeManager.manager.switchCurrentTheme(to: .dark)
  1. register theme loader:
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.bind UI like:

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
            }
        }

if use theme machine, you can use it like this:

self.view.fz_theme.appearance { (view, style, themeMachine) in
            view.layer.contents = themeMachine?.themeImage(withIdentifier: "backgroundImage", themeStyle: style, defaultImage: nil)?.cgImage
        }
  1. More to see Example Project

Author

FranZhou, fairytale_zf@outlook.com

License

FZTheme is available under the MIT license. See the LICENSE file for more info.

About

License:MIT License


Languages

Language:Swift 92.1%Language:Ruby 7.9%