Maintaining a colour theme manager on iOS swift

A guide on how to create a theme manager class in swift so that the code is flexible and the developer can change the theme colour anytime with ease.

Image for post
Image for post

Usage:

In your appdelegate: didFinishLaunchingWithOptions method, apply the theme as required.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {// Override point for customization after application launch.ThemeManager.applyTheme(theme: .theme1)return true}
import UIKitclass ViewController: UIViewController {let theme = ThemeManager.currentTheme()override func viewDidLoad() {super.viewDidLoad()self.view.backgroundColor = theme.backgroundColor}}

If you enjoyed reading this post, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store