To run the example project, clone the repo, and run pod install
from the Example directory first.
FZTheme is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'FZTheme'
- switch theme style:
FZThemeManager.manager.switchCurrentTheme(to: .dark)
- 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
}
- More to see Example Project
FranZhou, [email protected]
FZTheme is available under the MIT license. See the LICENSE file for more info.