Last active
August 18, 2016 19:35
-
-
Save bdalziel/7b2ca6afd058c30cc3a3 to your computer and use it in GitHub Desktop.
Relies on SwiftHEXColors for some nice UIColor extensions https://github.com/thii/SwiftHEXColors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppearanceManager.swift | |
// | |
// Created by Ben Dalziel on 2/17/16. | |
// | |
import UIKit | |
class AppearanceManager { | |
class func styleUINavigationBar() { | |
MyUINavigationBar.appearance().backgroundColor = ColorUtil.uiColor(AppUIColors.NavBarBackground) | |
MyUINavigationBar.appearance().tintColor = ColorUtil.uiColor(AppUIColors.NavBarTint) | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ColorUtil.swift | |
// | |
// Created by Ben Dalziel on 2/17/16. | |
// | |
import SwiftHEXColors | |
public indirect enum AppUIColors: Int { | |
case NavBarBackground, | |
NavBarTint, | |
NavBarShadow | |
} | |
class ColorUtil { | |
enum AppColors: String { | |
case Beige = "#f5efe0", | |
Gold = "#cda582", | |
// Alternate colors - use sparingly | |
GoldAlt = "#e1b996" | |
} | |
class func uiColor(appUIColor: AppUIColors) -> UIColor { | |
switch appUIColor { | |
case .NavBarBackground: | |
return color(AppColors.Beige) | |
case .NavBarTint : | |
return color(AppColors.Gold) | |
case .NavBarShadow : | |
return colorWithAlpha(AppColors.GoldAlt, alpha: 0.7) | |
} | |
} | |
// Conveniences unwrap raw value hex color value from enum | |
class func color(appColor: AppColors) -> UIColor { | |
return UIColor(hexString: appColor.rawValue)! | |
} | |
class func colorWithAlpha(appColor: AppColors, alpha: Float) -> UIColor { | |
return UIColor(hexString: appColor.rawValue, alpha: alpha)! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment