ThemeManager is a most lightweight, powerful, convenient and easiest way to manage your app themes, and also support change text(e.g. language) or other configurations dynamically too.
ThemeManager supports CocoaPods and Carthage. ThemeManager is written in Swift.
You can pull the ThemeManager Github Repo and include the ThemeManager.xcodeproj to build a dynamic or static library.
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate ThemeManager into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'WYZThemeManager'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate ThemeManager into your Xcode project using Carthage, specify it in your Cartfile
:
github "azone/ThemeManager" "master"
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but ThemeManager does support its use on supported platforms.
Once you have your Swift package set up, adding ThemeManager as a dependency is as easy as adding it to the dependencies value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/azone/ThemeManager.git", from: "0.3.0")
]
1. implement your self theme, language or other configuration (may be class, struct or anything you want) which must be conform Theme
protocol.
Example:
import ThemeManager
struct MyTheme: Theme {
var backgroundColor = UIColor.gray
var mainColor = UIColor.orange
var titleFont = UIFont.preferredFont(forTextStyle: .headline)
var subtitleFont = UIFont.preferredFont(forTextStyle: .subheadline)
var textColor = UIColor.red
var buttonTitleColor = UIColor.orange
var buttonTitleHighlightcolor = UIColor.red
var title = "Default Theme"
}
Example:
let themeManager = ThemeManager(MyTheme())
Example
themeManager.setup(view) { (view, theme) in
view.backgroundColor = theme.backgroundColor
}
themeManager.setup(navigationItem) { (item, theme) in
item.title = theme.title
}
themeManager.setup(navigationController?.navigationBar) { (bar, theme) in
bar.tintColor = theme.mainColor
bar.barTintColor = theme.backgroundColor
}
themeManager.apply(otherTheme)
ThemeManager is released under the MIT license. See LICENSE for details.