Skip to content
🎨 Simple way for Theme support in iOS apps
Swift Objective-C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Themeable.xcodeproj
Themeable
ThemeableExample/Example
.gitignore
.travis.yml
Cartfile
Cartfile.resolved
LICENSE
README.md

README.md

themeable

Themeable Build Status Carthage Swift License

Usage

Load your colors into Theme.shared using ThemeColors which conforms to Codeable, so you can load a JSON file from your Bundle (e.g. mytheme.json)

let myThemeColors = ThemeColors.load(bundle: "mytheme")

or any from any URL

let myThemeColors = ThemeColors.load(url: URL(string: "https://example.com/mytheme.json")!)

and apply the Theme using (if force is true it will also reload the current view=

Theme.shared.apply(force: true)

Example

Load your Theme mytheme.json at the start of the app.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Theme.shared.colors = ThemeColors.from(bundle: "mytheme")
    Theme.shared.apply(force: true)
    return true
}

Advanced

If your app is using Eureka you can enable support for it with Theme.shared.eureka = true

If you want to customize the colors (for example a user customizable global tint color) before applying the theme you can do so in

Theme.shared.customColor {
	// Load custom Colors, e.g.
	Theme.shared.tint = ... // Load user tint 
}

You can also add your custom apperance setters here

Theme.shared.customAppearances {
	// Load custom appearances, e.g.
	UIButton.appearance(whenContainedInInstancesOf [MyViewController.self]).backgroundColor = .green
}

Installation

Themeable is available through Carthage. To install just write into your Cartfile:

github "divadretlaw/Themeable"

License

See LICENSE

You can’t perform that action at this time.