Skip to content

FranZhou/FZTheme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, [email protected]

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published