Repository: vicc/chameleon Branch: master Commit: 6dd284bde21e Files: 72 Total size: 468.5 KB Directory structure: gitextract_5_vrjan2/ ├── .github/ │ └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── Chameleon/ │ ├── Chameleon.h │ └── Info.plist ├── Chameleon.xcodeproj/ │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ └── contents.xcworkspacedata │ └── xcshareddata/ │ └── xcschemes/ │ └── Chameleon.xcscheme ├── ChameleonDemo/ │ ├── AppDelegate.swift │ ├── Assets.xcassets/ │ │ └── AppIcon.appiconset/ │ │ └── Contents.json │ ├── Base.lproj/ │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── ChameleonDemo-ObjC/ │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets/ │ │ └── AppIcon.appiconset/ │ │ └── Contents.json │ ├── Base.lproj/ │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── ChameleonDemo-Swift/ │ ├── AppDelegate.swift │ ├── Assets.xcassets/ │ │ ├── AppIcon.appiconset/ │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── SampleImageOne.imageset/ │ │ │ └── Contents.json │ │ ├── SampleImageTwo.imageset/ │ │ │ └── Contents.json │ │ ├── first.imageset/ │ │ │ └── Contents.json │ │ ├── logo.imageset/ │ │ │ └── Contents.json │ │ └── second.imageset/ │ │ └── Contents.json │ ├── Base.lproj/ │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── FirstViewController.swift │ ├── Info.plist │ └── SecondViewController.swift ├── ChameleonFramework.podspec ├── Extras/ │ ├── Chameleon.clr │ ├── Chameleon.dmg │ ├── Chameleon.sketchpalette │ ├── Chameleon_Photoshop.aco │ └── Chameleon_v2.clr ├── LICENSE.md ├── Pod/ │ └── Classes/ │ ├── Objective-C/ │ │ ├── Chameleon.h │ │ ├── ChameleonConstants.h │ │ ├── ChameleonConstants.m │ │ ├── ChameleonEnums.h │ │ ├── ChameleonMacros.h │ │ ├── Chameleon_.h │ │ ├── Chameleon_.m │ │ ├── NSArray+Chameleon.h │ │ ├── NSArray+Chameleon.m │ │ ├── UIAppearance+Swift.h │ │ ├── UIAppearance+Swift.m │ │ ├── UIButton+Chameleon.h │ │ ├── UIButton+Chameleon.m │ │ ├── UIColor+Chameleon.h │ │ ├── UIColor+Chameleon.m │ │ ├── UIColor+ChameleonPrivate.h │ │ ├── UIColor+ChameleonPrivate.m │ │ ├── UIImage+ChameleonPrivate.h │ │ ├── UIImage+ChameleonPrivate.m │ │ ├── UILabel+Chameleon.h │ │ ├── UILabel+Chameleon.m │ │ ├── UINavigationController+Chameleon.h │ │ ├── UINavigationController+Chameleon.m │ │ ├── UIView+ChameleonPrivate.h │ │ ├── UIView+ChameleonPrivate.m │ │ ├── UIViewController+Chameleon.h │ │ └── UIViewController+Chameleon.m │ └── Swift/ │ └── ChameleonShorthand.swift └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ ====== Read this before submitting a new report ;) * Use the search function to find similar bugs before submitting a new one. * Bug related to Global theming ? Check #98 for a workaround or #74 #102 #153 #161. DELETE THIS TEXT BEFORE SUBMITING A NEW ISSUE. ====== ================================================ FILE: .gitignore ================================================ # Created by https://www.gitignore.io/ ## Build generated build/ DerivedData ## Various settings *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata ## Other *.xccheckout *.moved-aside *.xcuserstate *.xcscmblueprint ## Build generated build/ DerivedData ## Obj-C/Swift specific *.hmap *.ipa # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # Pods/ # Carthage # # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts Carthage/Build Carthage.checkout Carthage.build ================================================ FILE: CHANGELOG.md ================================================ ## 📄 Change Log ### 2.0.5 * Theme Support for UIImagePickerController (#83) * Objective-C Demo Project * Fixed Erroneous Swift Method Naming Convention Warnings * Bumped up the minimum version of iOS to `8.0`. * Fixed `If-Else` Statement Logic (#48) * Removed cast for `calloc` (#76). ### 2.0.4 * Minor Fixes. * Simplified `arrayOfColorsWithColorScheme` (#68) * `colorWithFlatVersionFrom` alpha bug fix (#69) ### 2.0.3 * Added `hidesNavigationBarHairline` boolean to UINavigationController, and by default it is now set to `NO`. (#64) * Improved Quick-Look Documentation for Theme Methods ### 2.0.2 * Carthage support added. (By [@bre7](https://github.com/bre7)) * Demo project added. (By [@bre7](https://github.com/bre7)) * Shields added to `README`. (By [@bre7](https://github.com/bre7)) * Fixed *'Wrong Navigation Bar Color'* bug. ([#51](https://github.com/ViccAlexander/Chameleon/issues/51)) (By [@bre7](https://github.com/bre7)) * Fixed *'Flatten'* bug. ([#53](https://github.com/ViccAlexander/Chameleon/issues/53)) (By [@bre7](https://github.com/bre7)) * Fixed *'EXC_BAD_ACCESS Error'* issue. ([#57](https://github.com/ViccAlexander/Chameleon/issues/57)) (By [@bre7](https://github.com/bre7)) * Several swift functions were made public. (By [@dexter505](https://github.com/dexter505)) ### 2.0.1 * Fixed *'ColorWithFlatVersionOf'* bug. ([#50](https://github.com/ViccAlexander/Chameleon/pull/50)) (By [@bre7](https://github.com/bre7)) ### 2.0.0 * Added support for hex colors, colors from images, themes, and lighten and darken by percentage methods. (By [@ViccAlexander](https://github.com/ViccAlexander)) ###### Added Methods **Chameleon.h** * `+ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle;` * `+ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle;` * `+ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle;` **NSArray+Chameleon.h** * `+ (NSArray *)arrayOfColorsFromImage:(UIImage *)image withFlatScheme (BOOL)isFlatScheme;` **UIColor+Chameleon.h** * `+ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image;` * `+ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha;` * `+ (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha;` * `+ (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha;` * `+ (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat alpha:(CGFloat)alpha;` * `+ (UIColor *)colorWithFlatVersionOf:(UIColor *)color withAlpha:(CGFloat)alpha;` * `+ (UIColor *)colorWithHexString:(NSString *)string;` * `+ (UIColor *)colorWithHexString:(NSString *)string withAlpha:(CGFloat)alpha;` * `- (UIColor *)flatten;` * `- (UIColor *)darkenByPercentage:(CGFloat)percentage;` * `- (UIColor *)lightenByPercentage:(CGFloat)percentage;` **UINavigationController+Chameleon.h** * `- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;` * `- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle;` * `- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle;` * `setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle;` * `- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;` ###### Deprecated Methods **NSArray+Chameleon.h** * ~~`+ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme `~~ > Replaced with: `+ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme usingColor:(UIColor *)color withFlatScheme:(BOOL)isFlatScheme;` **UIViewController+Chameleon.h** * ~~`- (void)flatify;`~~ * ~~`- (void)flatifyAndContrast;`~~ ###### Added Macros * `AverageColorFromImage(image)` * `AverageColorFromImageWithAlpha(image, alpha)` * `RandomFlatColorWithShadeAndAlpha(shade, alpha)` * `ColorsWithScheme(colorSchemeType, color, isFlatScheme)` * `ComplementaryFlatColorWithAlpha(color, alpha)` * `ContrastColorWithAlpha(backgroundColor, returnFlat, alpha)` * `HexColor(hexString)` * `HexColorWithAlpha(hexString, alpha)` * `RandomFlatColorWithShadeAndAlpha(shade, alpha)` * `ColorsFromImage(image, isFlatScheme)` ######Deprecated * `ColorsWithScheme(colorSchemeType, color, isFlatScheme)` > Replaced with: `ColorsWithScheme(colorSchemeType, color, isFlatScheme)` ### 1.2.1 • Added cocoapods support for Swift 2 *(Thanks to [**@bre7**](https://github.com/bre7))*. ### 1.2.0 • Fixed cocoapods installation error [#30](https://github.com/ViccAlexander/Chameleon/issues/30). • Updated Swift syntax to Swift 1.2 *(Fixed by [**@peacemoon**](https://github.com/peacemoon))*. • Split Objective-C & Swift Files into separate folders to keep files better organized. • Renamed `Constants.swift` to `ChameleonShorthand.swift` ###### Deprecated Methods * ~~`FlatVersionOfColor(color)`~~ * ~~`ColorScheme(colorSchemeType: ColorScheme, color: UIColor, isFlatScheme: Bool)`~~ Replaced with: `ColorSchemeOf(colorSchemeType: ColorScheme, color: UIColor, isFlatScheme: Bool)` due to naming constraints. ### 1.1.3 • Chameleon shorthand is now supported in Swift. *(Thanks to [**@bre7**](https://github.com/bre7))*. • Fixed Small Syntax Typo. *(Fixed by [**@ddwang**](https://github.com/ddwang))*. • Fixed issue where `-colorWithRandomFlatColorOfShadeStyle` always returns random color of `UIShadeStyleLight` *(Fixed by [**@smokyonion**](https://github.com/smokyonion))*. • UIGraphics context now uses the current screen's scale, preventing pixel wrap around for certain `UIColors` generated by `+ (UIColor *)colorWithGradientStyle` methods *(Fixed by [**@alist**](https://github.com/alist))*. • Removed warnings regarding the absolute value function `fabsf` *(Fixed by [**@jherran**](https://github.com/jherran))*. • Fixed the *`UIColor+Chameleon.m:444:13: code will never be executed*`, error state *(Fixed by [**@jherran**](https://github.com/jherran))*. ### 1.1.2 • Updated Copyright in all files and launch images • Added Launch Image in example project for iPhone 6 & iPhone 6 Plus • Replaced the reserved word `for` with the word `with` in `arrayOfColorsWithColorScheme` *(Fixed by [**@sfader**](https://github.com/sfader))*. ###### Deprecated Methods * ~~`initWithArray:for:flatScheme:`~~ Replaced with: `initWithArray:with:flatScheme:` ### 1.1.1 * ```ShadeStyle``` is now ```UIShadeStyle``` * ```GradientStyle``` is now ```UIGradientStyle``` * ```light``` is now ```UIShadeStyleLight``` * ```dark``` is now ```UIShadeStyleDark``` * ```linearGradientLeftToRight``` is now ```UIGradientStyleLeftToRight``` * ```linearGradientTopToBottom``` is now ```UIGradientStyleTopToBottom``` * Added: ```UIGradientStyleRadial``` ### 1.1.0 * Added Gradient Colors * Added Storyboard Palette Add-on * Added Xcode Quick Help Documentation Support * Switched from RGB colorspace to HSB & LAB colorspaces (closer to human perception) * Implemented `ContrastingColor` which supports all alphas and has additional support for non-flat and flat colors * Changed Color difference algorithm so that it now uses CIE:2000 formula * Changed `RandomFlatColors` from enum to nsarray values * Edited `RandomFlatColor` so that it will no longer spit out the same color back to back * Switched complementary and triadic fourth and fifth colors order. * New Macro: `ClearColor` ###### Deprecated Methods * ~~`colorWithContrastingBlackOrWhiteColorOn:`~~ Replaced with: `colorWithContrastingBlackOrWhiteColorOn:isFlat:` ###### Deprecated Macros * ~~`ContrastingColorOf(backgroundColor)`~~ Replaced with: `ContrastingColorOf(backgroundColor, isFlat)` * ~~`ComplementaryColorOf(color)`~~ Replaced with: `ComplementaryFlatColorOf(color)` * ~~`RandomColorWithShade(shade)`~~ Replaced with: `RandomFlatColorWithShade(shade)` ### 1.0.1 * Added Table of Contents * Fixed a couple of spelling errors * Extra '#define' deleted *(Fixed by [**@cascio**](https://github.com/cascio))*. * Imported UIKit in ChameleonStatusBar.h and NSArray+Chameleon.h *(Fixed by [**@jmhooper**](https://github.com/jmhooper))*. ================================================ FILE: Chameleon/Chameleon.h ================================================ // // Chameleon.h // Chameleon // // Created by Vicc Alexander on 9/24/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import //! Project version number for Chameleon. FOUNDATION_EXPORT double ChameleonVersionNumber; //! Project version string for Chameleon. FOUNDATION_EXPORT const unsigned char ChameleonVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import #import "Chameleon_.h" #import "UIButton+Chameleon.h" #import "UILabel+Chameleon.h" #import "UIColor+ChameleonPrivate.h" #import "UIImage+ChameleonPrivate.h" #import "UIView+ChameleonPrivate.h" #import "UIAppearance+Swift.h" #import "NSArray+Chameleon.h" #import "UIColor+Chameleon.h" #import "UINavigationController+Chameleon.h" #import "UIViewController+Chameleon.h" ================================================ FILE: Chameleon/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType FMWK CFBundleShortVersionString 2.0.6 CFBundleSignature ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass ================================================ FILE: Chameleon.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 0C6D34721C07B98400A7BF83 /* Chameleon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 240093F81BB4517400932727 /* Chameleon.framework */; }; 0C6D34731C07B98400A7BF83 /* Chameleon.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 240093F81BB4517400932727 /* Chameleon.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 0C8DABA81C07AC3800B28FE2 /* UIAppearance+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C8DABA61C07AC3800B28FE2 /* UIAppearance+Swift.m */; }; 0C8DABAB1C07B00000B28FE2 /* UIImage+ChameleonPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935E21BB4D62500C30559 /* UIImage+ChameleonPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0C8DABAC1C07B00800B28FE2 /* UIAppearance+Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C8DABA51C07AC3800B28FE2 /* UIAppearance+Swift.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0C8DABB51C07B5EA00B28FE2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C8DABB41C07B5EA00B28FE2 /* main.m */; }; 0C8DABB81C07B5EA00B28FE2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C8DABB71C07B5EA00B28FE2 /* AppDelegate.m */; }; 0C8DABBB1C07B5EA00B28FE2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C8DABBA1C07B5EA00B28FE2 /* ViewController.m */; }; 0C8DABBE1C07B5EA00B28FE2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C8DABBC1C07B5EA00B28FE2 /* Main.storyboard */; }; 0C8DABC01C07B5EA00B28FE2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C8DABBF1C07B5EA00B28FE2 /* Assets.xcassets */; }; 0C8DABC31C07B5EA00B28FE2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C8DABC11C07B5EA00B28FE2 /* LaunchScreen.storyboard */; }; 240093FC1BB4517400932727 /* Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 240093FB1BB4517400932727 /* Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935EC1BB4D62500C30559 /* Chameleon_.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935D41BB4D62500C30559 /* Chameleon_.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935ED1BB4D62500C30559 /* Chameleon_.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935D51BB4D62500C30559 /* Chameleon_.m */; }; 245935EE1BB4D62500C30559 /* ChameleonConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935D61BB4D62500C30559 /* ChameleonConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935EF1BB4D62500C30559 /* ChameleonConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935D71BB4D62500C30559 /* ChameleonConstants.m */; }; 245935F01BB4D62500C30559 /* ChameleonEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935D81BB4D62500C30559 /* ChameleonEnums.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935F11BB4D62500C30559 /* ChameleonMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935D91BB4D62500C30559 /* ChameleonMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935F21BB4D62500C30559 /* NSArray+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935DA1BB4D62500C30559 /* NSArray+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935F31BB4D62500C30559 /* NSArray+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935DB1BB4D62500C30559 /* NSArray+Chameleon.m */; }; 245935F41BB4D62500C30559 /* UIButton+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935DC1BB4D62500C30559 /* UIButton+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935F51BB4D62500C30559 /* UIButton+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935DD1BB4D62500C30559 /* UIButton+Chameleon.m */; }; 245935F61BB4D62500C30559 /* UIColor+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935DE1BB4D62500C30559 /* UIColor+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935F71BB4D62500C30559 /* UIColor+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935DF1BB4D62500C30559 /* UIColor+Chameleon.m */; }; 245935F81BB4D62500C30559 /* UIColor+ChameleonPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935E01BB4D62500C30559 /* UIColor+ChameleonPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935F91BB4D62500C30559 /* UIColor+ChameleonPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935E11BB4D62500C30559 /* UIColor+ChameleonPrivate.m */; }; 245935FB1BB4D62500C30559 /* UIImage+ChameleonPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935E31BB4D62500C30559 /* UIImage+ChameleonPrivate.m */; }; 245935FC1BB4D62500C30559 /* UILabel+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935E41BB4D62500C30559 /* UILabel+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935FD1BB4D62500C30559 /* UILabel+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935E51BB4D62500C30559 /* UILabel+Chameleon.m */; }; 245935FE1BB4D62500C30559 /* UINavigationController+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935E61BB4D62500C30559 /* UINavigationController+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245935FF1BB4D62500C30559 /* UINavigationController+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935E71BB4D62500C30559 /* UINavigationController+Chameleon.m */; }; 245936001BB4D62500C30559 /* UIView+ChameleonPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935E81BB4D62500C30559 /* UIView+ChameleonPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245936011BB4D62500C30559 /* UIView+ChameleonPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935E91BB4D62500C30559 /* UIView+ChameleonPrivate.m */; }; 245936021BB4D62500C30559 /* UIViewController+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 245935EA1BB4D62500C30559 /* UIViewController+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; 245936031BB4D62500C30559 /* UIViewController+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 245935EB1BB4D62500C30559 /* UIViewController+Chameleon.m */; }; 245936051BB4D62D00C30559 /* ChameleonShorthand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245936041BB4D62D00C30559 /* ChameleonShorthand.swift */; }; 246492FC1F0094DB001E4F26 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 246492FB1F0094DB001E4F26 /* AppDelegate.swift */; }; 246493011F0094DB001E4F26 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 246492FF1F0094DB001E4F26 /* Main.storyboard */; }; 246493031F0094DB001E4F26 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 246493021F0094DB001E4F26 /* Assets.xcassets */; }; 246493061F0094DB001E4F26 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 246493041F0094DB001E4F26 /* LaunchScreen.storyboard */; }; 247EB8AA1BB61EB3009B4904 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 247EB8A91BB61EB3009B4904 /* AppDelegate.swift */; }; 247EB8AC1BB61EB3009B4904 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 247EB8AB1BB61EB3009B4904 /* ViewController.swift */; }; 247EB8AF1BB61EB3009B4904 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 247EB8AD1BB61EB3009B4904 /* Main.storyboard */; }; 247EB8B11BB61EB3009B4904 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 247EB8B01BB61EB3009B4904 /* Assets.xcassets */; }; 247EB8B41BB61EB3009B4904 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 247EB8B21BB61EB3009B4904 /* LaunchScreen.storyboard */; }; 247EB8B91BB61F76009B4904 /* Chameleon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 240093F81BB4517400932727 /* Chameleon.framework */; }; 24D08ECB1F00954100D9F1A7 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D08EC91F00953A00D9F1A7 /* FirstViewController.swift */; }; 24D08ECC1F00954100D9F1A7 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D08ECA1F00953A00D9F1A7 /* SecondViewController.swift */; }; 24D08ECD1F00958200D9F1A7 /* Chameleon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 240093F81BB4517400932727 /* Chameleon.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 0C6D34741C07B98400A7BF83 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 240093EF1BB4517400932727 /* Project object */; proxyType = 1; remoteGlobalIDString = 240093F71BB4517400932727; remoteInfo = Chameleon; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ 0C6D34761C07B98400A7BF83 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( 0C6D34731C07B98400A7BF83 /* Chameleon.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 0C8DABA51C07AC3800B28FE2 /* UIAppearance+Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIAppearance+Swift.h"; path = "../Pod/Classes/Objective-C/UIAppearance+Swift.h"; sourceTree = ""; }; 0C8DABA61C07AC3800B28FE2 /* UIAppearance+Swift.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIAppearance+Swift.m"; path = "../Pod/Classes/Objective-C/UIAppearance+Swift.m"; sourceTree = ""; }; 0C8DABB11C07B5EA00B28FE2 /* ChameleonDemo-Objc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ChameleonDemo-Objc.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 0C8DABB41C07B5EA00B28FE2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 0C8DABB61C07B5EA00B28FE2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 0C8DABB71C07B5EA00B28FE2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 0C8DABB91C07B5EA00B28FE2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 0C8DABBA1C07B5EA00B28FE2 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 0C8DABBD1C07B5EA00B28FE2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 0C8DABBF1C07B5EA00B28FE2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 0C8DABC21C07B5EA00B28FE2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 0C8DABC41C07B5EA00B28FE2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 240093F81BB4517400932727 /* Chameleon.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Chameleon.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 240093FB1BB4517400932727 /* Chameleon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Chameleon.h; sourceTree = ""; }; 240093FD1BB4517400932727 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 245935D41BB4D62500C30559 /* Chameleon_.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chameleon_.h; path = "Pod/Classes/Objective-C/Chameleon_.h"; sourceTree = SOURCE_ROOT; }; 245935D51BB4D62500C30559 /* Chameleon_.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Chameleon_.m; path = "Pod/Classes/Objective-C/Chameleon_.m"; sourceTree = SOURCE_ROOT; }; 245935D61BB4D62500C30559 /* ChameleonConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChameleonConstants.h; path = "Pod/Classes/Objective-C/ChameleonConstants.h"; sourceTree = SOURCE_ROOT; }; 245935D71BB4D62500C30559 /* ChameleonConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ChameleonConstants.m; path = "Pod/Classes/Objective-C/ChameleonConstants.m"; sourceTree = SOURCE_ROOT; }; 245935D81BB4D62500C30559 /* ChameleonEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChameleonEnums.h; path = "Pod/Classes/Objective-C/ChameleonEnums.h"; sourceTree = SOURCE_ROOT; }; 245935D91BB4D62500C30559 /* ChameleonMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChameleonMacros.h; path = "Pod/Classes/Objective-C/ChameleonMacros.h"; sourceTree = SOURCE_ROOT; }; 245935DA1BB4D62500C30559 /* NSArray+Chameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSArray+Chameleon.h"; path = "Pod/Classes/Objective-C/NSArray+Chameleon.h"; sourceTree = SOURCE_ROOT; }; 245935DB1BB4D62500C30559 /* NSArray+Chameleon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSArray+Chameleon.m"; path = "Pod/Classes/Objective-C/NSArray+Chameleon.m"; sourceTree = SOURCE_ROOT; }; 245935DC1BB4D62500C30559 /* UIButton+Chameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIButton+Chameleon.h"; path = "Pod/Classes/Objective-C/UIButton+Chameleon.h"; sourceTree = SOURCE_ROOT; }; 245935DD1BB4D62500C30559 /* UIButton+Chameleon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIButton+Chameleon.m"; path = "Pod/Classes/Objective-C/UIButton+Chameleon.m"; sourceTree = SOURCE_ROOT; }; 245935DE1BB4D62500C30559 /* UIColor+Chameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+Chameleon.h"; path = "Pod/Classes/Objective-C/UIColor+Chameleon.h"; sourceTree = SOURCE_ROOT; }; 245935DF1BB4D62500C30559 /* UIColor+Chameleon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+Chameleon.m"; path = "Pod/Classes/Objective-C/UIColor+Chameleon.m"; sourceTree = SOURCE_ROOT; }; 245935E01BB4D62500C30559 /* UIColor+ChameleonPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+ChameleonPrivate.h"; path = "Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h"; sourceTree = SOURCE_ROOT; }; 245935E11BB4D62500C30559 /* UIColor+ChameleonPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+ChameleonPrivate.m"; path = "Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m"; sourceTree = SOURCE_ROOT; }; 245935E21BB4D62500C30559 /* UIImage+ChameleonPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+ChameleonPrivate.h"; path = "Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h"; sourceTree = SOURCE_ROOT; }; 245935E31BB4D62500C30559 /* UIImage+ChameleonPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ChameleonPrivate.m"; path = "Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m"; sourceTree = SOURCE_ROOT; }; 245935E41BB4D62500C30559 /* UILabel+Chameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UILabel+Chameleon.h"; path = "Pod/Classes/Objective-C/UILabel+Chameleon.h"; sourceTree = SOURCE_ROOT; }; 245935E51BB4D62500C30559 /* UILabel+Chameleon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UILabel+Chameleon.m"; path = "Pod/Classes/Objective-C/UILabel+Chameleon.m"; sourceTree = SOURCE_ROOT; }; 245935E61BB4D62500C30559 /* UINavigationController+Chameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UINavigationController+Chameleon.h"; path = "Pod/Classes/Objective-C/UINavigationController+Chameleon.h"; sourceTree = SOURCE_ROOT; }; 245935E71BB4D62500C30559 /* UINavigationController+Chameleon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UINavigationController+Chameleon.m"; path = "Pod/Classes/Objective-C/UINavigationController+Chameleon.m"; sourceTree = SOURCE_ROOT; }; 245935E81BB4D62500C30559 /* UIView+ChameleonPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+ChameleonPrivate.h"; path = "Pod/Classes/Objective-C/UIView+ChameleonPrivate.h"; sourceTree = SOURCE_ROOT; }; 245935E91BB4D62500C30559 /* UIView+ChameleonPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+ChameleonPrivate.m"; path = "Pod/Classes/Objective-C/UIView+ChameleonPrivate.m"; sourceTree = SOURCE_ROOT; }; 245935EA1BB4D62500C30559 /* UIViewController+Chameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIViewController+Chameleon.h"; path = "Pod/Classes/Objective-C/UIViewController+Chameleon.h"; sourceTree = SOURCE_ROOT; }; 245935EB1BB4D62500C30559 /* UIViewController+Chameleon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+Chameleon.m"; path = "Pod/Classes/Objective-C/UIViewController+Chameleon.m"; sourceTree = SOURCE_ROOT; }; 245936041BB4D62D00C30559 /* ChameleonShorthand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChameleonShorthand.swift; path = Pod/Classes/Swift/ChameleonShorthand.swift; sourceTree = SOURCE_ROOT; }; 246492F91F0094DB001E4F26 /* ChameleonDemo-Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ChameleonDemo-Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 246492FB1F0094DB001E4F26 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 246493001F0094DB001E4F26 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 246493021F0094DB001E4F26 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 246493051F0094DB001E4F26 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 246493071F0094DB001E4F26 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 247EB8A71BB61EB3009B4904 /* ChameleonDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChameleonDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 247EB8A91BB61EB3009B4904 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 247EB8AB1BB61EB3009B4904 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 247EB8AE1BB61EB3009B4904 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 247EB8B01BB61EB3009B4904 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 247EB8B31BB61EB3009B4904 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 247EB8B51BB61EB3009B4904 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24D08EC91F00953A00D9F1A7 /* FirstViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = ""; }; 24D08ECA1F00953A00D9F1A7 /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 0C8DABAE1C07B5EA00B28FE2 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 0C6D34721C07B98400A7BF83 /* Chameleon.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 240093F41BB4517400932727 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 246492F61F0094DB001E4F26 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 24D08ECD1F00958200D9F1A7 /* Chameleon.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 247EB8A41BB61EB3009B4904 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 247EB8B91BB61F76009B4904 /* Chameleon.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 0C8DABB21C07B5EA00B28FE2 /* ChameleonDemo-Objc */ = { isa = PBXGroup; children = ( 0C8DABB61C07B5EA00B28FE2 /* AppDelegate.h */, 0C8DABB71C07B5EA00B28FE2 /* AppDelegate.m */, 0C8DABB91C07B5EA00B28FE2 /* ViewController.h */, 0C8DABBA1C07B5EA00B28FE2 /* ViewController.m */, 0C8DABBC1C07B5EA00B28FE2 /* Main.storyboard */, 0C8DABBF1C07B5EA00B28FE2 /* Assets.xcassets */, 0C8DABC11C07B5EA00B28FE2 /* LaunchScreen.storyboard */, 0C8DABC41C07B5EA00B28FE2 /* Info.plist */, 0C8DABB31C07B5EA00B28FE2 /* Supporting Files */, ); path = "ChameleonDemo-Objc"; sourceTree = ""; }; 0C8DABB31C07B5EA00B28FE2 /* Supporting Files */ = { isa = PBXGroup; children = ( 0C8DABB41C07B5EA00B28FE2 /* main.m */, ); name = "Supporting Files"; sourceTree = ""; }; 240093EE1BB4517400932727 = { isa = PBXGroup; children = ( 240093FA1BB4517400932727 /* Chameleon */, 247EB8A81BB61EB3009B4904 /* ChameleonDemo */, 0C8DABB21C07B5EA00B28FE2 /* ChameleonDemo-Objc */, 246492FA1F0094DB001E4F26 /* ChameleonDemo-Swift */, 240093F91BB4517400932727 /* Products */, ); sourceTree = ""; }; 240093F91BB4517400932727 /* Products */ = { isa = PBXGroup; children = ( 240093F81BB4517400932727 /* Chameleon.framework */, 247EB8A71BB61EB3009B4904 /* ChameleonDemo.app */, 0C8DABB11C07B5EA00B28FE2 /* ChameleonDemo-Objc.app */, 246492F91F0094DB001E4F26 /* ChameleonDemo-Swift.app */, ); name = Products; sourceTree = ""; }; 240093FA1BB4517400932727 /* Chameleon */ = { isa = PBXGroup; children = ( 245936041BB4D62D00C30559 /* ChameleonShorthand.swift */, 240093FB1BB4517400932727 /* Chameleon.h */, 245935D41BB4D62500C30559 /* Chameleon_.h */, 245935D51BB4D62500C30559 /* Chameleon_.m */, 245935D61BB4D62500C30559 /* ChameleonConstants.h */, 245935D71BB4D62500C30559 /* ChameleonConstants.m */, 245935D81BB4D62500C30559 /* ChameleonEnums.h */, 245935D91BB4D62500C30559 /* ChameleonMacros.h */, 245935DA1BB4D62500C30559 /* NSArray+Chameleon.h */, 245935DB1BB4D62500C30559 /* NSArray+Chameleon.m */, 245935DC1BB4D62500C30559 /* UIButton+Chameleon.h */, 245935DD1BB4D62500C30559 /* UIButton+Chameleon.m */, 245935DE1BB4D62500C30559 /* UIColor+Chameleon.h */, 245935DF1BB4D62500C30559 /* UIColor+Chameleon.m */, 245935E01BB4D62500C30559 /* UIColor+ChameleonPrivate.h */, 245935E11BB4D62500C30559 /* UIColor+ChameleonPrivate.m */, 245935E21BB4D62500C30559 /* UIImage+ChameleonPrivate.h */, 245935E31BB4D62500C30559 /* UIImage+ChameleonPrivate.m */, 245935E41BB4D62500C30559 /* UILabel+Chameleon.h */, 245935E51BB4D62500C30559 /* UILabel+Chameleon.m */, 245935E61BB4D62500C30559 /* UINavigationController+Chameleon.h */, 245935E71BB4D62500C30559 /* UINavigationController+Chameleon.m */, 245935E81BB4D62500C30559 /* UIView+ChameleonPrivate.h */, 245935E91BB4D62500C30559 /* UIView+ChameleonPrivate.m */, 245935EA1BB4D62500C30559 /* UIViewController+Chameleon.h */, 245935EB1BB4D62500C30559 /* UIViewController+Chameleon.m */, 0C8DABA51C07AC3800B28FE2 /* UIAppearance+Swift.h */, 0C8DABA61C07AC3800B28FE2 /* UIAppearance+Swift.m */, 240093FD1BB4517400932727 /* Info.plist */, ); path = Chameleon; sourceTree = ""; }; 246492FA1F0094DB001E4F26 /* ChameleonDemo-Swift */ = { isa = PBXGroup; children = ( 246492FB1F0094DB001E4F26 /* AppDelegate.swift */, 24D08EC91F00953A00D9F1A7 /* FirstViewController.swift */, 24D08ECA1F00953A00D9F1A7 /* SecondViewController.swift */, 246492FF1F0094DB001E4F26 /* Main.storyboard */, 246493021F0094DB001E4F26 /* Assets.xcassets */, 246493041F0094DB001E4F26 /* LaunchScreen.storyboard */, 246493071F0094DB001E4F26 /* Info.plist */, ); path = "ChameleonDemo-Swift"; sourceTree = ""; }; 247EB8A81BB61EB3009B4904 /* ChameleonDemo */ = { isa = PBXGroup; children = ( 247EB8A91BB61EB3009B4904 /* AppDelegate.swift */, 247EB8AB1BB61EB3009B4904 /* ViewController.swift */, 247EB8AD1BB61EB3009B4904 /* Main.storyboard */, 247EB8B01BB61EB3009B4904 /* Assets.xcassets */, 247EB8B21BB61EB3009B4904 /* LaunchScreen.storyboard */, 247EB8B51BB61EB3009B4904 /* Info.plist */, ); path = ChameleonDemo; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 240093F51BB4517400932727 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 245935F41BB4D62500C30559 /* UIButton+Chameleon.h in Headers */, 245935FC1BB4D62500C30559 /* UILabel+Chameleon.h in Headers */, 245935F21BB4D62500C30559 /* NSArray+Chameleon.h in Headers */, 240093FC1BB4517400932727 /* Chameleon.h in Headers */, 245935EC1BB4D62500C30559 /* Chameleon_.h in Headers */, 245935FE1BB4D62500C30559 /* UINavigationController+Chameleon.h in Headers */, 245935F11BB4D62500C30559 /* ChameleonMacros.h in Headers */, 245936001BB4D62500C30559 /* UIView+ChameleonPrivate.h in Headers */, 245935F61BB4D62500C30559 /* UIColor+Chameleon.h in Headers */, 245935F01BB4D62500C30559 /* ChameleonEnums.h in Headers */, 245935EE1BB4D62500C30559 /* ChameleonConstants.h in Headers */, 245935F81BB4D62500C30559 /* UIColor+ChameleonPrivate.h in Headers */, 245936021BB4D62500C30559 /* UIViewController+Chameleon.h in Headers */, 0C8DABAB1C07B00000B28FE2 /* UIImage+ChameleonPrivate.h in Headers */, 0C8DABAC1C07B00800B28FE2 /* UIAppearance+Swift.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 0C8DABB01C07B5EA00B28FE2 /* ChameleonDemo-Objc */ = { isa = PBXNativeTarget; buildConfigurationList = 0C8DABC51C07B5EA00B28FE2 /* Build configuration list for PBXNativeTarget "ChameleonDemo-Objc" */; buildPhases = ( 0C8DABAD1C07B5EA00B28FE2 /* Sources */, 0C8DABAE1C07B5EA00B28FE2 /* Frameworks */, 0C8DABAF1C07B5EA00B28FE2 /* Resources */, 0C6D34761C07B98400A7BF83 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( 0C6D34751C07B98400A7BF83 /* PBXTargetDependency */, ); name = "ChameleonDemo-Objc"; productName = "ChameleonDemo-Objc"; productReference = 0C8DABB11C07B5EA00B28FE2 /* ChameleonDemo-Objc.app */; productType = "com.apple.product-type.application"; }; 240093F71BB4517400932727 /* Chameleon */ = { isa = PBXNativeTarget; buildConfigurationList = 240094001BB4517400932727 /* Build configuration list for PBXNativeTarget "Chameleon" */; buildPhases = ( 240093F31BB4517400932727 /* Sources */, 240093F41BB4517400932727 /* Frameworks */, 240093F51BB4517400932727 /* Headers */, 240093F61BB4517400932727 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = Chameleon; productName = Chameleon; productReference = 240093F81BB4517400932727 /* Chameleon.framework */; productType = "com.apple.product-type.framework"; }; 246492F81F0094DB001E4F26 /* ChameleonDemo-Swift */ = { isa = PBXNativeTarget; buildConfigurationList = 2464930A1F0094DB001E4F26 /* Build configuration list for PBXNativeTarget "ChameleonDemo-Swift" */; buildPhases = ( 246492F51F0094DB001E4F26 /* Sources */, 246492F61F0094DB001E4F26 /* Frameworks */, 246492F71F0094DB001E4F26 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = "ChameleonDemo-Swift"; productName = "ChameleonDemo-Swift"; productReference = 246492F91F0094DB001E4F26 /* ChameleonDemo-Swift.app */; productType = "com.apple.product-type.application"; }; 247EB8A61BB61EB3009B4904 /* ChameleonDemo */ = { isa = PBXNativeTarget; buildConfigurationList = 247EB8B81BB61EB3009B4904 /* Build configuration list for PBXNativeTarget "ChameleonDemo" */; buildPhases = ( 247EB8A31BB61EB3009B4904 /* Sources */, 247EB8A41BB61EB3009B4904 /* Frameworks */, 247EB8A51BB61EB3009B4904 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = ChameleonDemo; productName = ChameleonDemo; productReference = 247EB8A71BB61EB3009B4904 /* ChameleonDemo.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 240093EF1BB4517400932727 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0900; LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Vicc Alexander"; TargetAttributes = { 0C8DABB01C07B5EA00B28FE2 = { CreatedOnToolsVersion = 7.1.1; }; 240093F71BB4517400932727 = { CreatedOnToolsVersion = 7.0; LastSwiftMigration = 0800; }; 246492F81F0094DB001E4F26 = { CreatedOnToolsVersion = 9.0; }; 247EB8A61BB61EB3009B4904 = { CreatedOnToolsVersion = 7.0; LastSwiftMigration = 0800; }; }; }; buildConfigurationList = 240093F21BB4517400932727 /* Build configuration list for PBXProject "Chameleon" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 240093EE1BB4517400932727; productRefGroup = 240093F91BB4517400932727 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 240093F71BB4517400932727 /* Chameleon */, 247EB8A61BB61EB3009B4904 /* ChameleonDemo */, 0C8DABB01C07B5EA00B28FE2 /* ChameleonDemo-Objc */, 246492F81F0094DB001E4F26 /* ChameleonDemo-Swift */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 0C8DABAF1C07B5EA00B28FE2 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 0C8DABC31C07B5EA00B28FE2 /* LaunchScreen.storyboard in Resources */, 0C8DABC01C07B5EA00B28FE2 /* Assets.xcassets in Resources */, 0C8DABBE1C07B5EA00B28FE2 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 240093F61BB4517400932727 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 246492F71F0094DB001E4F26 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 246493061F0094DB001E4F26 /* LaunchScreen.storyboard in Resources */, 246493031F0094DB001E4F26 /* Assets.xcassets in Resources */, 246493011F0094DB001E4F26 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 247EB8A51BB61EB3009B4904 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 247EB8B41BB61EB3009B4904 /* LaunchScreen.storyboard in Resources */, 247EB8B11BB61EB3009B4904 /* Assets.xcassets in Resources */, 247EB8AF1BB61EB3009B4904 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 0C8DABAD1C07B5EA00B28FE2 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 0C8DABBB1C07B5EA00B28FE2 /* ViewController.m in Sources */, 0C8DABB81C07B5EA00B28FE2 /* AppDelegate.m in Sources */, 0C8DABB51C07B5EA00B28FE2 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 240093F31BB4517400932727 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 245935F91BB4D62500C30559 /* UIColor+ChameleonPrivate.m in Sources */, 245935F51BB4D62500C30559 /* UIButton+Chameleon.m in Sources */, 245935F31BB4D62500C30559 /* NSArray+Chameleon.m in Sources */, 245935FD1BB4D62500C30559 /* UILabel+Chameleon.m in Sources */, 245935FB1BB4D62500C30559 /* UIImage+ChameleonPrivate.m in Sources */, 245935EF1BB4D62500C30559 /* ChameleonConstants.m in Sources */, 245936051BB4D62D00C30559 /* ChameleonShorthand.swift in Sources */, 245936031BB4D62500C30559 /* UIViewController+Chameleon.m in Sources */, 245935FF1BB4D62500C30559 /* UINavigationController+Chameleon.m in Sources */, 0C8DABA81C07AC3800B28FE2 /* UIAppearance+Swift.m in Sources */, 245936011BB4D62500C30559 /* UIView+ChameleonPrivate.m in Sources */, 245935ED1BB4D62500C30559 /* Chameleon_.m in Sources */, 245935F71BB4D62500C30559 /* UIColor+Chameleon.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 246492F51F0094DB001E4F26 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 24D08ECC1F00954100D9F1A7 /* SecondViewController.swift in Sources */, 24D08ECB1F00954100D9F1A7 /* FirstViewController.swift in Sources */, 246492FC1F0094DB001E4F26 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 247EB8A31BB61EB3009B4904 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 247EB8AC1BB61EB3009B4904 /* ViewController.swift in Sources */, 247EB8AA1BB61EB3009B4904 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 0C6D34751C07B98400A7BF83 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 240093F71BB4517400932727 /* Chameleon */; targetProxy = 0C6D34741C07B98400A7BF83 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 0C8DABBC1C07B5EA00B28FE2 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 0C8DABBD1C07B5EA00B28FE2 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; 0C8DABC11C07B5EA00B28FE2 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( 0C8DABC21C07B5EA00B28FE2 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; 246492FF1F0094DB001E4F26 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 246493001F0094DB001E4F26 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; 246493041F0094DB001E4F26 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( 246493051F0094DB001E4F26 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; 247EB8AD1BB61EB3009B4904 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 247EB8AE1BB61EB3009B4904 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; 247EB8B21BB61EB3009B4904 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( 247EB8B31BB61EB3009B4904 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 0C8DABC61C07B5EA00B28FE2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; INFOPLIST_FILE = "ChameleonDemo-Objc/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.viccalexander.ChameleonDemo-Objc"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; 0C8DABC71C07B5EA00B28FE2 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; INFOPLIST_FILE = "ChameleonDemo-Objc/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.viccalexander.ChameleonDemo-Objc"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; 240093FE1BB4517400932727 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Debug; }; 240093FF1BB4517400932727 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Release; }; 240094011BB4517400932727 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Chameleon/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.Chameleon; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; }; name = Debug; }; 240094021BB4517400932727 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Chameleon/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.Chameleon; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_VERSION = 3.0; }; name = Release; }; 246493081F0094DB001E4F26 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "ChameleonDemo-Swift/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.viccalexander.ChameleonDemo-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; 246493091F0094DB001E4F26 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "ChameleonDemo-Swift/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.viccalexander.ChameleonDemo-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; 247EB8B61BB61EB3009B4904 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = ChameleonDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.ChameleonDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; name = Debug; }; 247EB8B71BB61EB3009B4904 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = ChameleonDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.ChameleonDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 0C8DABC51C07B5EA00B28FE2 /* Build configuration list for PBXNativeTarget "ChameleonDemo-Objc" */ = { isa = XCConfigurationList; buildConfigurations = ( 0C8DABC61C07B5EA00B28FE2 /* Debug */, 0C8DABC71C07B5EA00B28FE2 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 240093F21BB4517400932727 /* Build configuration list for PBXProject "Chameleon" */ = { isa = XCConfigurationList; buildConfigurations = ( 240093FE1BB4517400932727 /* Debug */, 240093FF1BB4517400932727 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 240094001BB4517400932727 /* Build configuration list for PBXNativeTarget "Chameleon" */ = { isa = XCConfigurationList; buildConfigurations = ( 240094011BB4517400932727 /* Debug */, 240094021BB4517400932727 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 2464930A1F0094DB001E4F26 /* Build configuration list for PBXNativeTarget "ChameleonDemo-Swift" */ = { isa = XCConfigurationList; buildConfigurations = ( 246493081F0094DB001E4F26 /* Debug */, 246493091F0094DB001E4F26 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 247EB8B81BB61EB3009B4904 /* Build configuration list for PBXNativeTarget "ChameleonDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( 247EB8B61BB61EB3009B4904 /* Debug */, 247EB8B71BB61EB3009B4904 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 240093EF1BB4517400932727 /* Project object */; } ================================================ FILE: Chameleon.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: Chameleon.xcodeproj/xcshareddata/xcschemes/Chameleon.xcscheme ================================================ ================================================ FILE: ChameleonDemo/AppDelegate.swift ================================================ // // AppDelegate.swift // ChameleonDemo // // Created by Vicc Alexander on 9/25/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // import UIKit import Chameleon @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { Chameleon.setGlobalThemeUsingPrimaryColor(.flatPlum, withSecondaryColor: .flatBlue, andContentStyle: .contrast) return true } } ================================================ FILE: ChameleonDemo/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "1x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "2x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "1x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "2x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "1x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "2x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo/Base.lproj/LaunchScreen.storyboard ================================================ ================================================ FILE: ChameleonDemo/Base.lproj/Main.storyboard ================================================ ================================================ FILE: ChameleonDemo/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 2.0.6 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance ================================================ FILE: ChameleonDemo/ViewController.swift ================================================ // // ViewController.swift // ChameleonDemo // // Created by Vicc Alexander on 9/25/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // import UIKit import Chameleon class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = GradientColor(UIGradientStyle.leftToRight, frame: view.frame, colors: [UIColor.black, UIColor.yellow]) } } ================================================ FILE: ChameleonDemo-ObjC/AppDelegate.h ================================================ // // AppDelegate.h // ChameleonDemo-Objc // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import @import Chameleon; @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @end ================================================ FILE: ChameleonDemo-ObjC/AppDelegate.m ================================================ // // AppDelegate.m // ChameleonDemo-Objc // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Set global theme [Chameleon setGlobalThemeUsingPrimaryColor:FlatMint withSecondaryColor:FlatBlue andContentStyle:UIContentStyleContrast]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end ================================================ FILE: ChameleonDemo-ObjC/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-ObjC/Base.lproj/LaunchScreen.storyboard ================================================ ================================================ FILE: ChameleonDemo-ObjC/Base.lproj/Main.storyboard ================================================ ================================================ FILE: ChameleonDemo-ObjC/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 2.0.6 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance ================================================ FILE: ChameleonDemo-ObjC/ViewController.h ================================================ // // ViewController.h // ChameleonDemo-Objc // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import @import Chameleon; @interface ViewController : UIViewController @end ================================================ FILE: ChameleonDemo-ObjC/ViewController.m ================================================ // // ViewController.m // ChameleonDemo-Objc // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { //Super [super viewDidLoad]; //Set View Background self.view.backgroundColor = FlatYellow; } - (void)didReceiveMemoryWarning { //Super [super didReceiveMemoryWarning]; } @end ================================================ FILE: ChameleonDemo-ObjC/main.m ================================================ // // main.m // ChameleonDemo-Objc // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } ================================================ FILE: ChameleonDemo-Swift/AppDelegate.swift ================================================ // // AppDelegate.swift // ChameleonDemo // // Created by Wei Huang on 5/5/17. // Copyright © 2017 Wei Huang. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return true } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "20x20", "scale" : "2x" }, { "idiom" : "iphone", "size" : "20x20", "scale" : "3x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "size" : "60x60", "idiom" : "iphone", "filename" : "Demo-1.png", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" }, { "idiom" : "ios-marketing", "size" : "1024x1024", "scale" : "1x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/SampleImageOne.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "SampleImageOne-1.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/SampleImageTwo.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "SampleImageTwo-1.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/first.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "first.pdf" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/logo.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "logo@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Assets.xcassets/second.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "second.pdf" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: ChameleonDemo-Swift/Base.lproj/LaunchScreen.storyboard ================================================ ================================================ FILE: ChameleonDemo-Swift/Base.lproj/Main.storyboard ================================================ ================================================ FILE: ChameleonDemo-Swift/FirstViewController.swift ================================================ // // FirstViewController.swift // ChameleonDemo // // Created by Wei Huang on 5/5/17. // Copyright © 2017 Wei Huang. All rights reserved. // import UIKit import Chameleon class FirstViewController: UITableViewController { @IBOutlet weak var randomFlatColorLabel: UILabel! @IBOutlet weak var complementaryFlatColorLabel: UILabel! @IBOutlet weak var contrastFlatColorLabel: UILabel! @IBOutlet weak var flatteningNonFlatColorLabel: UILabel! @IBOutlet weak var beforeFlatteningColorLabel: UILabel! @IBOutlet weak var lighterColorLabel: UILabel! @IBOutlet weak var darkerColorLabel: UILabel! @IBOutlet weak var gradientColorLabel: UILabel! @IBOutlet weak var gradientComponentColorOneLabel: UILabel! @IBOutlet weak var gradientComponentColorTwoLabel: UILabel! @IBOutlet weak var gradientComponentColorThreeLabel: UILabel! @IBOutlet weak var gradientWithContrastLabel: UILabel! @IBOutlet weak var refreshButton: UIBarButtonItem! // MARK: Life cycles override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. initChameleonColors() // Hide nav bar hairline self.navigationController?.hidesNavigationBarHairline = true } override func viewWillAppear(_ animated: Bool) { // initChameleonColors() } // MARK: Chameleon related func initChameleonColors() { let randomFlatColor = UIColor.randomFlat let randomFlatColorContract = ContrastColorOf(randomFlatColor, returnFlat: true) // Nav bar navigationController?.navigationBar.barTintColor = randomFlatColor navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: randomFlatColorContract] // Tab bar tabBarController?.tabBar.barTintColor = randomFlatColor tabBarController?.tabBar.tintColor = randomFlatColorContract // Refresh button refreshButton.tintColor = randomFlatColorContract // Random flat color randomFlatColorLabel.text = "Aa \u{25A0}" randomFlatColorLabel.textColor = randomFlatColor // Complementary flat color complementaryFlatColorLabel.text = "Aa \u{25A0}" complementaryFlatColorLabel.textColor = ComplementaryFlatColorOf(randomFlatColor) // Contrast flat color contrastFlatColorLabel.text = "Aa \u{25A0}" contrastFlatColorLabel.textColor = ContrastColorOf(randomFlatColor, returnFlat: true) // Flattening non-flat color let randomColor = generateRandomColor() // custom method, not part of Chameleon flatteningNonFlatColorLabel.text = "Aa \u{25A0}" flatteningNonFlatColorLabel.textColor = randomColor.flatten() beforeFlatteningColorLabel.text = "Aa \u{25A0}" beforeFlatteningColorLabel.textColor = randomColor // Lighter color > not yet reliable lighterColorLabel.text = "Aa \u{25A0}" lighterColorLabel.textColor = randomFlatColor.lighten(byPercentage: 0.5) // Darker color > not yet reliable darkerColorLabel.text = "Aa \u{25A0}" darkerColorLabel.textColor = randomFlatColor.darken(byPercentage: 0.5) // Gradient color let firstRandomColor = UIColor.randomFlat let secondRandomColor = UIColor.randomFlat let thirdRandomColor = UIColor.randomFlat let gradientColor = GradientColor(.leftToRight, frame: gradientColorLabel.frame, colors: [firstRandomColor, secondRandomColor, thirdRandomColor]) let gradientColorLargeFrame = GradientColor(.leftToRight, frame: gradientWithContrastLabel.frame, colors: [firstRandomColor, secondRandomColor, thirdRandomColor]) gradientColorLabel.text = "Aa \u{25A0}" gradientColorLabel.textColor = gradientColor // Gradient backgorund with contrast text gradientComponentColorOneLabel.text = "\u{25A0}" gradientComponentColorOneLabel.textColor = firstRandomColor gradientComponentColorTwoLabel.text = "\u{25A0}" gradientComponentColorTwoLabel.textColor = secondRandomColor gradientComponentColorThreeLabel.text = "\u{25A0}" gradientComponentColorThreeLabel.textColor = thirdRandomColor gradientWithContrastLabel.text = "FANCY COLOR" gradientWithContrastLabel.textColor = ContrastColorOf(gradientColorLargeFrame, returnFlat: true) gradientWithContrastLabel.backgroundColor = gradientColorLargeFrame gradientWithContrastLabel.layer.masksToBounds = true gradientWithContrastLabel.layer.cornerRadius = 8 } // Refresh colors @IBAction func refreshButtonAction(_ sender: Any) { initChameleonColors() } // Generate a random color func generateRandomColor() -> UIColor { let red = Float(arc4random_uniform(256))/255.0 let green = Float(arc4random_uniform(256))/255.0 let blue = Float(arc4random_uniform(256))/255.0 return UIColor(colorLiteralRed: red, green: green, blue: blue, alpha: 1.0) } } ================================================ FILE: ChameleonDemo-Swift/Info.plist ================================================ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: ChameleonDemo-Swift/SecondViewController.swift ================================================ // // SecondViewController.swift // ChameleonDemo // // Created by Wei Huang on 5/5/17. // Copyright © 2017 Wei Huang. All rights reserved. // // - Attribution: image #1 - vecteezy.com // - Attribution: image #1 - 500px.com import UIKit import Chameleon class SecondViewController: UITableViewController { @IBOutlet weak var sampleOneImageView: UIImageView! @IBOutlet weak var sampleOneAverageColorLabel: UILabel! @IBOutlet weak var sampleOneComponentColorOneLabel: UILabel! @IBOutlet weak var sampleOneComponentColorTwoLabel: UILabel! @IBOutlet weak var sampleOneComponentColorThreeLabel: UILabel! @IBOutlet weak var sampleOneComponentColorFourLabel: UILabel! @IBOutlet weak var sampleOneComponentColorFiveLabel: UILabel! @IBOutlet weak var sampleTwoImageView: UIImageView! @IBOutlet weak var sampleTwoAverageColorLabel: UILabel! @IBOutlet weak var sampleTwoComponentColorOneLabel: UILabel! @IBOutlet weak var sampleTwoComponentColorTwoLabel: UILabel! @IBOutlet weak var sampleTwoComponentColorThreeLabel: UILabel! @IBOutlet weak var sampleTwoComponentColorFourLabel: UILabel! @IBOutlet weak var sampleTwoComponentColorFiveLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: tabBarController?.tabBar.tintColor ?? UIColor.gray] navigationController?.navigationBar.barTintColor = tabBarController?.tabBar.barTintColor ?? UIColor.lightGray sampleOneImageView.image = #imageLiteral(resourceName: "SampleImageOne") sampleTwoImageView.image = #imageLiteral(resourceName: "SampleImageTwo") sampleOneImageView.layer.masksToBounds = true sampleTwoImageView.layer.masksToBounds = true sampleOneImageView.layer.cornerRadius = 8 sampleTwoImageView.layer.cornerRadius = 8 initChameleon() } override func viewWillAppear(_ animated: Bool) { navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: tabBarController?.tabBar.tintColor ?? UIColor.gray] navigationController?.navigationBar.barTintColor = tabBarController?.tabBar.barTintColor ?? UIColor.lightGray } // Chameleon related func initChameleon() { let sampleOneImageColors = ColorsFromImage(#imageLiteral(resourceName: "SampleImageOne"), withFlatScheme: true) print(sampleOneImageColors.count) let sampleTwoImageColors = ColorsFromImage(#imageLiteral(resourceName: "SampleImageTwo"), withFlatScheme: true) print(sampleTwoImageColors.count) let sampleOneImageAverageColor = AverageColorFromImage(#imageLiteral(resourceName: "SampleImageOne")) let sampleTwoImageAverageColor = AverageColorFromImage(#imageLiteral(resourceName: "SampleImageTwo")) sampleOneAverageColorLabel.text = "Aa \u{25A0}" sampleOneAverageColorLabel.textColor = sampleOneImageAverageColor sampleTwoAverageColorLabel.text = "Aa \u{25A0}" sampleTwoAverageColorLabel.textColor = sampleTwoImageAverageColor sampleOneComponentColorOneLabel.text = "\u{25A0}" sampleOneComponentColorOneLabel.textColor = sampleOneImageColors[0] sampleOneComponentColorTwoLabel.text = "\u{25A0}" sampleOneComponentColorTwoLabel.textColor = sampleOneImageColors[1] sampleOneComponentColorThreeLabel.text = "\u{25A0}" sampleOneComponentColorThreeLabel.textColor = sampleOneImageColors[2] sampleOneComponentColorFourLabel.text = "\u{25A0}" sampleOneComponentColorFourLabel.textColor = sampleOneImageColors[3] sampleOneComponentColorFiveLabel.text = "\u{25A0}" sampleOneComponentColorFiveLabel.textColor = sampleOneImageColors[4] sampleTwoComponentColorOneLabel.text = "\u{25A0}" sampleTwoComponentColorOneLabel.textColor = sampleOneImageColors[0] sampleTwoComponentColorTwoLabel.text = "\u{25A0}" sampleTwoComponentColorTwoLabel.textColor = sampleOneImageColors[1] sampleTwoComponentColorThreeLabel.text = "\u{25A0}" sampleTwoComponentColorThreeLabel.textColor = sampleOneImageColors[2] sampleTwoComponentColorFourLabel.text = "\u{25A0}" sampleTwoComponentColorFourLabel.textColor = sampleOneImageColors[3] sampleTwoComponentColorFiveLabel.text = "\u{25A0}" sampleTwoComponentColorFiveLabel.textColor = sampleOneImageColors[4] } } ================================================ FILE: ChameleonFramework.podspec ================================================ Pod::Spec.new do |s| s.name = "ChameleonFramework" s.version = "2.1.0" s.summary = "Color Framework for iOS (Obj-C & Swift)" s.homepage = "https://github.com/ViccAlexander/Chameleon" s.screenshots = "https://camo.githubusercontent.com/bde5aa6ee0e1feec044d184a735da8024c60c04c/687474703a2f2f692e696d6775722e636f6d2f427771486842342e706e67" s.license = { :type => "MIT", :file => "LICENSE.md" } s.author = "Vicc Alexander" s.social_media_url = "http://twitter.com/ViccsMind" s.platform = :ios s.ios.deployment_target = '8.0' s.source = { :git => "https://github.com/ViccAlexander/Chameleon.git", :tag => s.version.to_s } s.public_header_files = 'Pod/Classes/Objective-C/**/*.h' s.frameworks = 'UIKit', 'QuartzCore', 'CoreGraphics' s.default_subspecs = 'Default' s.subspec 'Default' do |ss| ss.source_files = 'Pod/Classes/Objective-C/**/*.{h,m}' end s.subspec 'Swift' do |ss| ss.ios.deployment_target = '8.0' ss.source_files = 'Pod/Classes/Swift/ChameleonShorthand.swift' ss.dependency 'ChameleonFramework/Default' end end ================================================ FILE: Extras/Chameleon.sketchpalette ================================================ {"compatibleVersion":"1.0","pluginVersion":"1.1","colors":["#E64E42","#BF3A31","#E57F31","#D25519","#FFCC2F","#FEA829","#F0DEB7","#D5C298","#354A5D","#2D3E50","#2B2B2B","#262626","#9B5DB5","#8D48AB","#3C7080","#376272","#3B9AD9","#2F81B8","#39CB75","#30AD63","#2ABC9D","#23A086","#EDF1F2","#BEC4C8","#808C8D","#365F42","#2E5037","#7561C3","#5B4BA1","#5E4536","#503B2D","#5D365D","#4F2C4F","#ED737D","#D8565C","#A6C646","#8FAF30","#F37FC3","#D35F9E","#78312C","#652723","#A38673","#8D7260","#B9CAF0","#9AABD2","#5167A0","#3A4E7F"]} ================================================ FILE: LICENSE.md ================================================ ##The MIT License (MIT) > Copyright (c) 2014-2015 Vicc Alexander > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal > in the Software without restriction, including without limitation the rights > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > copies of the Software, and to permit persons to whom the Software is > furnished to do so, subject to the following conditions: > The above copyright notice and this permission notice shall be included in all > copies or substantial portions of the Software. > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > SOFTWARE. ================================================ FILE: Pod/Classes/Objective-C/Chameleon.h ================================================ // // Chameleon.h // Chameleon // // Created by Vicc Alexander on 9/24/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import //! Project version number for Chameleon. FOUNDATION_EXPORT double ChameleonVersionNumber; //! Project version string for Chameleon. FOUNDATION_EXPORT const unsigned char ChameleonVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import #import "Chameleon_.h" #import "UIButton+Chameleon.h" #import "UILabel+Chameleon.h" #import "UIColor+ChameleonPrivate.h" #import "UIImage+ChameleonPrivate.h" #import "UIView+ChameleonPrivate.h" #import "UIAppearance+Swift.h" #import "NSArray+Chameleon.h" #import "UIColor+Chameleon.h" #import "UINavigationController+Chameleon.h" #import "UIViewController+Chameleon.h" ================================================ FILE: Pod/Classes/Objective-C/ChameleonConstants.h ================================================ // // Constants.h // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import #import /** * A contrasting status bar, intended for use on any backgrounds. * * @since 2.0 */ extern const UIStatusBarStyle UIStatusBarStyleContrast; @interface ChameleonConstants : NSObject @end ================================================ FILE: Pod/Classes/Objective-C/ChameleonConstants.m ================================================ // // Constants.m // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "ChameleonConstants.h" const UIStatusBarStyle UIStatusBarStyleContrast = 100; @implementation ChameleonConstants @end ================================================ FILE: Pod/Classes/Objective-C/ChameleonEnums.h ================================================ // // ChameleonEnums.h // Chameleon // // Created by Vicc Alexander on 6/8/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #ifndef Chameleon_ChameleonEnums_h #define Chameleon_ChameleonEnums_h /** * Specifies how text-based UI elements and other content such as switch knobs, should be colored. * * @since 2.0 */ typedef NS_ENUM(NSUInteger, UIContentStyle) { /** * Automatically chooses and colors text-based elements with the shade that best contrasts its @c backgroundColor. * * @since 2.0 */ UIContentStyleContrast, /** * Colors text-based elements using a light shade. * * @since 2.0 */ UIContentStyleLight, /** * Colors text-based elements using a light shade. * * @since 2.0 */ UIContentStyleDark }; #endif ================================================ FILE: Pod/Classes/Objective-C/ChameleonMacros.h ================================================ // ChameleonMacros.h /* The MIT License (MIT) Copyright (c) 2014-2015 Vicc Alexander. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #import "UIColor+Chameleon.h" #pragma mark - Light Shades Shorthand #define FlatBlack [UIColor flatBlackColor] #define FlatBlue [UIColor flatBlueColor] #define FlatBrown [UIColor flatBrownColor] #define FlatCoffee [UIColor flatCoffeeColor] #define FlatForestGreen [UIColor flatForestGreenColor] #define FlatGray [UIColor flatGrayColor] #define FlatGreen [UIColor flatGreenColor] #define FlatLime [UIColor flatLimeColor] #define FlatMagenta [UIColor flatMagentaColor] #define FlatMaroon [UIColor flatMaroonColor] #define FlatMint [UIColor flatMintColor] #define FlatNavyBlue [UIColor flatNavyBlueColor] #define FlatOrange [UIColor flatOrangeColor] #define FlatPink [UIColor flatPinkColor] #define FlatPlum [UIColor flatPlumColor] #define FlatPowderBlue [UIColor flatPowderBlueColor] #define FlatPurple [UIColor flatPurpleColor] #define FlatRed [UIColor flatRedColor] #define FlatSand [UIColor flatSandColor] #define FlatSkyBlue [UIColor flatSkyBlueColor] #define FlatTeal [UIColor flatTealColor] #define FlatWatermelon [UIColor flatWatermelonColor] #define FlatWhite [UIColor flatWhiteColor] #define FlatYellow [UIColor flatYellowColor] // --------------------------------------------------- #pragma mark - Dark Shades Shorthand #define FlatBlackDark [UIColor flatBlackDarkColor] #define FlatBlueDark [UIColor flatBlueDarkColor] #define FlatBrownDark [UIColor flatBrownDarkColor] #define FlatCoffeeDark [UIColor flatCoffeeDarkColor] #define FlatForestGreenDark [UIColor flatForestGreenDarkColor] #define FlatGrayDark [UIColor flatGrayDarkColor] #define FlatGreenDark [UIColor flatGreenDarkColor] #define FlatLimeDark [UIColor flatLimeDarkColor] #define FlatMagentaDark [UIColor flatMagentaDarkColor] #define FlatMaroonDark [UIColor flatMaroonDarkColor] #define FlatMintDark [UIColor flatMintDarkColor] #define FlatNavyBlueDark [UIColor flatNavyBlueDarkColor] #define FlatOrangeDark [UIColor flatOrangeDarkColor] #define FlatPinkDark [UIColor flatPinkDarkColor] #define FlatPlumDark [UIColor flatPlumDarkColor] #define FlatPowderBlueDark [UIColor flatPowderBlueDarkColor] #define FlatPurpleDark [UIColor flatPurpleDarkColor] #define FlatRedDark [UIColor flatRedDarkColor] #define FlatSandDark [UIColor flatSandDarkColor] #define FlatSkyBlueDark [UIColor flatSkyBlueDarkColor] #define FlatTealDark [UIColor flatTealDarkColor] #define FlatWatermelonDark [UIColor flatWatermelonDarkColor] #define FlatWhiteDark [UIColor flatWhiteDarkColor] #define FlatYellowDark [UIColor flatYellowDarkColor] // --------------------------------------------------- #pragma mark - Special Colors Shorthand #define RandomFlatColor [UIColor randomFlatColor] #define ClearColor [UIColor clearColor] // --------------------------------------------------- #pragma mark - UIColor Methods Shorthand #define AverageColorFromImage(image) [UIColor colorWithAverageColorFromImage:image] #define AverageColorFromImageWithAlpha(image, alpha) [UIColor colorWithAverageColorFromImage:image withAlpha:alpha] #define ComplementaryFlatColor(color) [UIColor colorWithComplementaryFlatColorOf:color] #define ComplementaryFlatColorWithAlpha(color, alpha) [UIColor colorWithComplementaryFlatColorOf:color withAlpha:alpha] #define ContrastColor(backgroundColor, returnFlat) [UIColor colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:returnFlat] #define ContrastColorWithAlpha(backgroundColor, returnFlat, alpha) [UIColor colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:returnFlat alpha:alpha] #define GradientColor(gradientStyle, frame, colors) [UIColor colorWithGradientStyle:gradientStyle withFrame:frame andColors:colors] #define HexColor(hexString) [UIColor colorWithHexString:hexString] #define HexColorWithAlpha(hexString, alpha) [UIColor colorWithHexString:hexString withAlpha:alpha] #define RandomFlatColorInArray(colors) [UIColor colorWithRandomColorInArray:colors] #define RandomFlatColorExcluding(colors) [UIColor colorWithRandomFlatColorExcludingColorsInArray:colors]; #define RandomFlatColorWithShade(shade) [UIColor colorWithRandomFlatColorOfShadeStyle:shade] #define RandomFlatColorWithShadeAndAlpha(shade, alpha) [UIColor colorWithRandomFlatColorOfShadeStyle:shade withAlpha:alpha] // --------------------------------------------------- #pragma mark - NSArray Shorthand #define ColorsWithScheme(colorSchemeType, color, isFlatScheme) [NSArray arrayOfColorsWithColorScheme:colorSchemeType usingColor:color withFlatScheme:isFlatScheme] #define ColorsFromImage(image, isFlatScheme) [NSArray arrayOfColorsFromImage:image withFlatScheme:isFlatScheme] ================================================ FILE: Pod/Classes/Objective-C/Chameleon_.h ================================================ // // ChameleonInternal.h // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import #import #import "ChameleonConstants.h" #import "ChameleonEnums.h" #import "ChameleonMacros.h" #import "NSArray+Chameleon.h" #import "UIColor+Chameleon.h" #import "UINavigationController+Chameleon.h" #import "UIViewController+Chameleon.h" @interface Chameleon : NSObject #pragma mark - Global Theming /** * Set a global theme using a primary color and the specified content style. * * @param primaryColor The primary color to theme all controllers with. * @param contentStyle The contentStyle. * * @note By default the secondary color will be a darker shade of the specified primary color. * * @since 2.0 */ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle; /** * Set a global theme using a primary color, secondary color, and the specified content style. * * @param primaryColor The primary color to theme all controllers with. * @param secondaryColor The secondary color to theme all controllers with. * @param contentStyle The contentStyle. * * @since 2.0 */ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle; /** * Set a global theme using a primary color, secondary color, font name, and the specified content style. * * @param primaryColor The primary color to theme all controllers with. * @param secondaryColor The secondary color to theme all controllers with. * @param fontName The default font for all text-based UI elements. * @param contentStyle The contentStyle. * * @since 2.0 */ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle; @end ================================================ FILE: Pod/Classes/Objective-C/Chameleon_.m ================================================ // // ChameleonInternal.m // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "Chameleon_.h" #import "UILabel+Chameleon.h" #import "UIButton+Chameleon.h" #import "UIAppearance+Swift.h" @implementation Chameleon #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[UILabel appearance] setSubstituteFontName:fontName]; [[UIButton appearance] setSubstituteFontName:fontName]; [[self class] customizeNavigationBarWithBarColor:primaryColor textColor:ContrastColor(primaryColor, YES) fontName:fontName fontSize:20 buttonColor:ContrastColor(primaryColor, YES)]; [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withFontName:fontName withFontSize:14 withContentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; /* if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor fontName:fontName fontSize:17 contentStyle:contentStyle]; [[self class] customizeLabelWithPrimaryColor:primaryColor fontName:fontName fontSize:18 withContentStyle:contentStyle]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite tintColor:primaryColor fontName:fontName fontSize:11]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; */ } #pragma mark - UIBarButtonItem + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor contentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIBarButtonItem appearance] setTintColor:primaryColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; } + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor fontName:(NSString *)fontName fontSize:(float)fontSize contentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIBarButtonItem appearance] setTintColor:primaryColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; if ([UIFont fontWithName:fontName size:fontSize]) { [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{ NSForegroundColorAttributeName:contentColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize]} forState:UIControlStateNormal]; } } #pragma mark - UIButton + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIButton appearance] setTintColor:contentColor]; [[UIButton appearance] setBackgroundColor:primaryColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; } + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor secondaryColor:(UIColor *)secondaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; UIColor *secondaryContentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); secondaryContentColor = ContrastColor(secondaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; secondaryContentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; secondaryContentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); secondaryContentColor = ContrastColor(secondaryColor, NO); break; } } [[UIButton appearance] setTintColor:secondaryContentColor]; [[UIButton appearance] setBackgroundColor:secondaryColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; } #pragma mark - UIImagePickerController + (void)customizeImagePickerControllerWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } //Workaround for Swift http://stackoverflow.com/a/28765193 [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setTintColor:ClearColor]; [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; [[UIButton appearanceWhenContainedWithin:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setTintColor:contentColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; } #pragma mark - UILabel + (void)customizeLabelWithPrimaryColor:(UIColor *)primaryColor fontName:(NSString *)fontName fontSize:(CGFloat)fontSize withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UILabel appearanceWhenContainedIn:[UINavigationBar class], nil] setTextColor:contentColor]; [[UILabel appearanceWhenContainedIn:[UIToolbar class], nil] setTextColor:contentColor]; UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UILabel appearance] setFont:[UIFont fontWithName:fontName size:fontSize]]; [[UILabel appearanceWhenContainedIn:[UITextField class], nil] setFont:[UIFont fontWithName:fontName size:14]]; [[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:fontName size:18]]; } } #pragma mark - UINavigationBar + (void)customizeNavigationBarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UINavigationBar appearance] setBarTintColor:primaryColor]; [[UINavigationBar appearance] setTintColor:contentColor]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:contentColor}]; [[UINavigationBar appearance] setShadowImage:[UIImage new]]; // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor textColor:(UIColor *)textColor buttonColor:(UIColor *)buttonColor { [[UINavigationBar appearance] setBarTintColor:barColor]; [[UINavigationBar appearance] setTintColor:buttonColor]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:textColor}]; [[UINavigationBar appearance] setShadowImage:[UIImage new]]; // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor textColor:(UIColor *)textColor fontName:(NSString *)fontName fontSize:(CGFloat)fontSize buttonColor:(UIColor *)buttonColor { [[UINavigationBar appearance] setBarTintColor:barColor]; [[UINavigationBar appearance] setTintColor:buttonColor]; [[UINavigationBar appearance] setShadowImage:[UIImage new]]; // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; if ([UIFont fontWithName:fontName size:fontSize]) { [[UINavigationBar appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:textColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize] }]; } } #pragma mark - UIPageControl + (void)customizePageControlWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIPageControl appearance] setCurrentPageIndicatorTintColor:primaryColor]; [[UIPageControl appearance] setPageIndicatorTintColor:[primaryColor colorWithAlphaComponent:0.4]]; [[UIPageControl appearanceWhenContainedIn:[UINavigationBar class], nil] setCurrentPageIndicatorTintColor:contentColor]; [[UIPageControl appearanceWhenContainedIn:[UINavigationBar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; [[UIPageControl appearanceWhenContainedIn:[UIToolbar class], nil] setCurrentPageIndicatorTintColor:contentColor]; [[UIPageControl appearanceWhenContainedIn:[UIToolbar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; } #pragma mark - UIProgressView + (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIProgressView appearance] setProgressTintColor:primaryColor]; [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setProgressTintColor:contentColor]; [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setProgressTintColor:contentColor]; [[UIProgressView appearance] setTrackTintColor:[UIColor lightGrayColor]]; [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } + (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor andSecondaryColor:(UIColor *)secondaryColor { [[UIProgressView appearance] setProgressTintColor:secondaryColor]; [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setProgressTintColor:secondaryColor]; [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setProgressTintColor:secondaryColor]; [[UIProgressView appearance] setTrackTintColor:[UIColor lightGrayColor]]; [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } #pragma mark - UISearchBar + (void)customizeSearchBarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISearchBar appearance] setBarTintColor:primaryColor]; [[UISearchBar appearance] setBackgroundColor:primaryColor]; [[UISearchBar appearance] setTintColor:contentColor]; [[UISearchBar appearance] setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; } #pragma mark - UISegmentedControl + (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISegmentedControl appearance] setTintColor:primaryColor]; [[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UISegmentedControl appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; } + (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor withFontName:(NSString *)fontName withFontSize:(CGFloat)fontSize withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISegmentedControl appearance] setTintColor:primaryColor]; [[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UISegmentedControl appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UISegmentedControl appearance] setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateNormal]; } } #pragma mark - UISlider + (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISlider appearance] setMinimumTrackTintColor:primaryColor]; [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMinimumTrackTintColor:contentColor]; [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMinimumTrackTintColor:contentColor]; [[UISlider appearance] setMaximumTrackTintColor:[UIColor lightGrayColor]]; [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISlider appearance] setThumbTintColor:primaryColor]; [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setThumbTintColor:contentColor]; } + (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor andSecondaryColor:(UIColor *)secondaryColor { [[UISlider appearance] setMinimumTrackTintColor:secondaryColor]; [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMinimumTrackTintColor:secondaryColor]; [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMinimumTrackTintColor:secondaryColor]; [[UISlider appearance] setMaximumTrackTintColor:[UIColor lightGrayColor]]; [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISlider appearance] setThumbTintColor:secondaryColor]; [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setThumbTintColor:ContrastColor(primaryColor, NO)]; } #pragma mark - UIStepper + (void)customizeStepperWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIStepper appearance] setTintColor:primaryColor]; [[UIStepper appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIStepper appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; } #pragma mark - UISwitch + (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor { [[UISwitch appearance] setOnTintColor:primaryColor]; [[UISwitch appearanceWhenContainedIn:[UINavigationBar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISwitch appearanceWhenContainedIn:[UIToolbar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } + (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor andSecondaryColor:(UIColor *)secondaryColor { [[UISwitch appearance] setOnTintColor:secondaryColor]; [[UISwitch appearanceWhenContainedIn:[UINavigationBar class], nil] setOnTintColor:secondaryColor]; [[UISwitch appearanceWhenContainedIn:[UIToolbar class], nil] setOnTintColor:secondaryColor]; } #pragma mark - UITabBar + (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor andTintColor:(UIColor *)tintColor { [[UITabBar appearance] setBarTintColor:barTintColor]; [[UITabBar appearance] setTintColor:tintColor]; } + (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor tintColor:(UIColor *)tintColor fontName:(NSString *)fontName fontSize:(CGFloat)fontSize { [[UITabBar appearance] setBarTintColor:barTintColor]; [[UITabBar appearance] setTintColor:tintColor]; UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateNormal]; } } #pragma mark - UIToolbar + (void)customizeToolbarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIToolbar appearance] setTintColor:contentColor]; [[UIToolbar appearance] setBarTintColor:primaryColor]; [[UIToolbar appearance] setClipsToBounds:YES]; } #pragma GCC diagnostic pop @end ================================================ FILE: Pod/Classes/Objective-C/NSArray+Chameleon.h ================================================ // NSArray+Chameleon.h /* The MIT License (MIT) Copyright (c) 2014-2015 Vicc Alexander. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #import #import #pragma mark - Enums /** * Color schemes with which to select colors using a specified color. * * @since 1.0 */ typedef NS_ENUM(NSInteger, ColorScheme){ /** * Analogous color schemes use colors that are next to each other on the color wheel. They usually match well and create serene and comfortable designs. Analogous color schemes are often found in nature and are harmonious and pleasing to the eye. Make sure you have enough contrast when choosing an analogous color scheme. Choose one color to dominate, a second to support. The third color is used (along with black, white or gray) as an accent. * * @since 1.0 */ ColorSchemeAnalogous, /** * A triadic color scheme uses colors that are evenly spaced around the color wheel. Triadic color harmonies tend to be quite vibrant, even if you use pale or unsaturated versions of your hues. To use a triadic harmony successfully, the colors should be carefully balanced - let one color dominate and use the two others for accent. * * @since 1.0 */ ColorSchemeTriadic, /** * Colors that are opposite each other on the color wheel are considered to be complementary colors (example: red and green). The high contrast of complementary colors creates a vibrant look especially when used at full saturation. This color scheme must be managed well so it is not jarring. Complementary colors are tricky to use in large doses, but work well when you want something to stand out. Complementary colors are really bad for text. * * @since 1.0 */ ColorSchemeComplementary }; @interface NSArray (Chameleon) #pragma mark - Generating Color Schemes /** * Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. * * @param colorScheme The color scheme with which to select colors using a specified color. * @param color The specified color which the color scheme is built around. * @param isFlatScheme Pass YES to return flat color objects. * * @return An array of 5 color objects in the HSB colorspace. * * @since 2.0 */ + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme usingColor:(UIColor *)color withFlatScheme:(BOOL)isFlatScheme; /** * Generates and creates an array of 5 color objects in the HSB colorspace that appear most often in a specified image. * * @param image The specified image which the color scheme is built around. * @param isFlatScheme Pass YES to return flat color objects. * * @return An array of 5 color objects in the HSB colorspace. * * @since 2.0 */ + (NSArray *)arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)isFlatScheme; #pragma mark - Deprecated Methods /** * Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. * * @param colorScheme The color scheme with which to select colors using a specified color. * * @param color The specified color which the color scheme is built around. * * @param isFlatScheme Pass YES to return flat color objects. * * @return An array of 5 color objects in the HSB colorspace. * * @since 1.1.2 */ + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme __attribute((deprecated(" Use -arrayOfColorsWithColorScheme:usingColor:withFlatScheme: instead (First deprecated in Chameleon 2.0)."))); @end ================================================ FILE: Pod/Classes/Objective-C/NSArray+Chameleon.m ================================================ // NSArray+Chameleon.m /* The MIT License (MIT) Copyright (c) 2014-2015 Vicc Alexander. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #import "NSArray+Chameleon.h" #import "ChameleonMacros.h" #import "UIColor+ChameleonPrivate.h" #import "UIImage+ChameleonPrivate.h" @interface ChameleonCountedColor : NSObject @property (assign) NSUInteger count; @property (strong) UIColor *color; - (id)initWithColor:(UIColor *)color count:(NSUInteger)count; @end @implementation NSArray (Chameleon) #pragma mark - Deprecated 2.0 + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme { //Extract HSB values from input color CGFloat h, s, b, a; [color getHue:&h saturation:&s brightness:&b alpha:&a]; //Multiply our values by the max value to convert h *= 360; s *= 100; b *= 100; //Choose Between Schemes switch (colorScheme) { case ColorSchemeAnalogous: return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; case ColorSchemeComplementary: return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; case ColorSchemeTriadic: return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; default: NSAssert(0, @"Oops! Unrecognized color scheme provided as random color."); } } #pragma mark - Chameleon - Public Color Scheme Methods + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme usingColor:(UIColor *)color withFlatScheme:(BOOL)isFlatScheme { //Extract HSB values from input color CGFloat h, s, b, a; [color getHue:&h saturation:&s brightness:&b alpha:&a]; //Multiply our values by the max value to convert h *= 360; s *= 100; b *= 100; //Choose Between Schemes switch (colorScheme) { case ColorSchemeAnalogous: if (isFlatScheme) return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; else return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; case ColorSchemeComplementary: if (isFlatScheme) return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; else return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; case ColorSchemeTriadic: if (isFlatScheme) return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; else return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; default: NSAssert(0, @"Oops! Unrecognized color scheme provided as random color."); } } + (NSArray *)arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)isFlatScheme { //Quick return in case we don't have an image if (!image) { //Make sure we return some colors to prevent exception NSMutableArray *emptyColors = [NSMutableArray array]; while (emptyColors.count < 5) { [emptyColors addObject:[UIColor whiteColor]]; } return emptyColors; } //Scale image UIImage *scaledImage = [UIImage imageWithImage:image scaledToSize:CGSizeMake(image.size.width/8, image.size.height/8)]; NSMutableArray *finalColors = [NSMutableArray array]; //Find colors in image ********************************* //Get dimensions of image in pixels size_t width = CGImageGetWidth(scaledImage.CGImage); size_t height = CGImageGetHeight(scaledImage.CGImage); //Initialize a counted set with the correct capacity NSCountedSet *imageColors = [[NSCountedSet alloc] initWithCapacity:(width * height)]; //Loop through each column for (NSUInteger x = 0; x < width; x++) { //Loop through each row for (NSUInteger y = 0; y < height; y++) { //Get color at a specific point UIColor *color = [UIColor colorFromImage:scaledImage atPoint:CGPointMake(x, y)]; //Add color to our list of all pixel colors [imageColors addObject:color]; } } //Setup up an enumerator object NSEnumerator *enumerator = [imageColors objectEnumerator]; UIColor *currentColor; NSMutableArray *sortedColors = [NSMutableArray arrayWithCapacity:imageColors.count]; NSMutableArray *resultColors = [NSMutableArray array]; //Enumerate through each object once while ((currentColor = [enumerator nextObject]) != nil) { //Set a minimum allowed saturation currentColor = [currentColor colorWithMinimumSaturation:0.15f]; //Get color count NSUInteger colorCount = [imageColors countForObject:currentColor]; //Add them to our sortedColors array [sortedColors addObject:[[ChameleonCountedColor alloc] initWithColor:currentColor count:colorCount]]; } //Sort Colors [sortedColors sortUsingSelector:@selector(compare:)]; //Loop through our sorted colors for (ChameleonCountedColor *countedColor in sortedColors) { //Define our current color currentColor = countedColor.color; //Setup a flag to see if we should continue counting BOOL continueFlag = NO; //Loop through our colors for (UIColor *otherColor in resultColors) { //If our current color differs from our last, break the loop if (![currentColor isDistinct:otherColor]) { continueFlag = YES; break; } } //Continue if (continueFlag) { continue; } //If we can still add more colors, do so if (resultColors.count < 5) { //Check if we should flatten our color if (isFlatScheme) { [resultColors addObject:[currentColor flatten]]; } else { [resultColors addObject:currentColor]; } } else { break; } } //Get colors from image [finalColors addObjectsFromArray:[NSArray arrayWithArray:resultColors]]; // ***************************************************** //Make sure we add white colors in case we're missing colors while (finalColors.count < 5) { [finalColors addObject:[UIColor whiteColor]]; } //Return array of colors return [NSArray arrayWithArray:finalColors]; } - (NSArray *)findColorsOfImage:(UIImage *)image imageColors:(NSCountedSet * __autoreleasing *)colors { //Get dimensions of image in pixels size_t width = CGImageGetWidth(image.CGImage); size_t height = CGImageGetHeight(image.CGImage); //Initialize a counted set with the correct capacity NSCountedSet *imageColors = [[NSCountedSet alloc] initWithCapacity:(width * height)]; //Loop through each column for (NSUInteger x = 0; x < width; x++) { //Loop through each row for (NSUInteger y = 0; y < height; y++) { //Get color at a specific point UIColor *color = [UIColor colorFromImage:image atPoint:CGPointMake(x, y)]; //Add color to our list of all pixel colors [imageColors addObject:color]; } } //Assign imageColors to colors *colors = imageColors; //Setup up an enumerator object NSEnumerator *enumerator = [imageColors objectEnumerator]; UIColor *currentColor; NSMutableArray *sortedColors = [NSMutableArray arrayWithCapacity:imageColors.count]; NSMutableArray *resultColors = [NSMutableArray array]; //Enumerate through each object once while ((currentColor = [enumerator nextObject]) != nil) { //Set a minimum allowed saturation currentColor = [currentColor colorWithMinimumSaturation:0.15f]; //Get color count NSUInteger colorCount = [imageColors countForObject:currentColor]; //Add them to our sortedColors array [sortedColors addObject:[[ChameleonCountedColor alloc] initWithColor:currentColor count:colorCount]]; } //Sort Colors [sortedColors sortUsingSelector:@selector(compare:)]; //Loop through our sorted colors for (ChameleonCountedColor *countedColor in sortedColors) { //Define our current color currentColor = countedColor.color; //Setup a flag to see if we should continue counting BOOL continueFlag = NO; //Loop through our colors for (UIColor *c in resultColors) { //If our current color differs from our last, break the loop if (![currentColor isDistinct:c]) { continueFlag = YES; break; } } //Continue if (continueFlag) { continue; } //If we can still add more colors, do so if (resultColors.count < self.count) { [resultColors addObject:currentColor]; } else { break; } } //Return our colors return [NSArray arrayWithArray:resultColors]; } #pragma mark - Chameleon - Internal Color Scheme Methods //Creates an array with 2 analagous colors on each side of the predefined color + (NSArray *)analogousColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { UIColor *firstColor = [UIColor colorWithHue:([[self class] add:-32 to:h])/360 saturation:(s+5)/100 brightness:(b+5)/100 alpha:1.0]; UIColor *secondColor = [UIColor colorWithHue:[[self class] add:-16 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0]; UIColor *thirdColor = [UIColor colorWithHue:h/360 saturation:s/100 brightness:b/100 alpha:1.0]; UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:16 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0]; UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:32 to:h]/360 saturation:(s+5)/100 brightness:(b+5)/100 alpha:1.0]; if (isFlat) { //Flatten colors firstColor = [firstColor flatten]; secondColor = [secondColor flatten]; thirdColor = [thirdColor flatten]; fourthColor = [fourthColor flatten]; fifthColor = [fifthColor flatten]; //Make sure returned colors are unique //Inner Colors if ([secondColor isEqual:thirdColor]) { secondColor = [[UIColor colorWithHue:[[self class] add:-48 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0] flatten]; } if ([thirdColor isEqual:fourthColor]) { fourthColor = [[UIColor colorWithHue:[[self class] add:32 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0] flatten]; } //Outer Colors if ([firstColor isEqual:secondColor]) { firstColor = [[UIColor colorWithHue:[[self class] add:-64 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0] flatten]; } if ([firstColor isEqual:thirdColor]) { firstColor = [[UIColor colorWithHue:[[self class] add:-96 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0] darkenByPercentage:0.25]; } if ([fourthColor isEqual:fifthColor]) { fifthColor = [[UIColor colorWithHue:[[self class] add:64 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0] flatten]; } if ([thirdColor isEqual:fifthColor]) { fifthColor = [[UIColor colorWithHue:[[self class] add:96 to:h]/360 saturation:(s+5)/100 brightness:(b+9)/100 alpha:1.0] flatten]; } } return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; } // Creates an array of 5 colors, both 90 degrees and 180 degrees away from the predefined colors on both sides + (NSArray *)complementaryColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { UIColor *firstColor = [UIColor colorWithHue:h/360 saturation:(s+5)/100 brightness:(b-30)/100 alpha:1.0]; UIColor *secondColor = [UIColor colorWithHue:h/360 saturation:(s-10)/100 brightness:(b+9)/100 alpha:1.0]; UIColor *thirdColor = [UIColor colorWithHue:h/360 saturation:s/100 brightness:b/100 alpha:1.0]; UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:180 to:h]/360 saturation:s/100 brightness:b/100 alpha:1.0]; UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:180 to:h]/360 saturation:(s+20)/100 brightness:(b-30)/100 alpha:1.0]; if (isFlat) { //Flatten colors firstColor = [firstColor flatten]; secondColor = [secondColor flatten]; thirdColor = [thirdColor flatten]; fourthColor = [fourthColor flatten]; fifthColor = [fifthColor flatten]; //Make sure returned colors are unique //Inner Colors if ([secondColor isEqual:thirdColor]) { secondColor = [[secondColor darkenByPercentage:0.25] flatten]; } if ([thirdColor isEqual:fourthColor]) { fourthColor = [[fourthColor darkenByPercentage:0.25] flatten]; } if ([firstColor isEqual:thirdColor]) { firstColor = [[firstColor darkenByPercentage:0.25] flatten]; } if ([fifthColor isEqual:thirdColor]) { fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; } //Outer Colors if ([firstColor isEqual:secondColor]) { firstColor = [[firstColor darkenByPercentage:0.25] flatten]; } if ([fourthColor isEqual:fifthColor]) { fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; } } return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; } // Creates an array of 5 colors, both 120 degrees and 240 degrees away from the predefined colors on both sides + (NSArray *)triadicColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { UIColor *firstColor = [UIColor colorWithHue:[[self class] add:120 to:h]/360 saturation:(7*s/6)/100 brightness:(b-5)/100 alpha:1.0]; UIColor *secondColor = [UIColor colorWithHue:[[self class] add:120 to:h]/360 saturation:s/100 brightness:(b+9)/100 alpha:1.0]; UIColor *thirdColor = [UIColor colorWithHue:h/360 saturation:s/100 brightness:b/100 alpha:1.0]; UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:240 to:h]/360 saturation:(7*s/6)/100 brightness:(b-5)/100 alpha:1.0]; UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:240 to:h]/360 saturation:s/100 brightness:(b-30)/100 alpha:1.0]; if (isFlat) { //Flatten colors firstColor = [firstColor flatten]; secondColor = [secondColor flatten]; thirdColor = [thirdColor flatten]; fourthColor = [fourthColor flatten]; fifthColor = [fifthColor flatten]; //Make sure returned colors are unique //Inner Colors if ([secondColor isEqual:thirdColor]) { secondColor = [[secondColor darkenByPercentage:0.25] flatten]; } if ([thirdColor isEqual:fourthColor]) { fourthColor = [[fourthColor darkenByPercentage:0.25] flatten]; } if ([firstColor isEqual:thirdColor]) { firstColor = [[firstColor darkenByPercentage:0.25] flatten]; } if ([fifthColor isEqual:thirdColor]) { fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; } //Outer Colors if ([firstColor isEqual:secondColor]) { firstColor = [[firstColor darkenByPercentage:0.25] flatten]; } if ([fourthColor isEqual:fifthColor]) { fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; } } return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; } #pragma mark - Helper Methods for Color Schemes + (float)add:(float)newValue to:(float)currentValue { currentValue += newValue; //Check if currentValue exceeds 360 degrees if (currentValue > 360) { float offset = currentValue - 360; return offset; } else if (currentValue < 0) { return -1 * currentValue; } else { return currentValue; } } + (UIColor *)colorWithFlatVersionOf:(UIColor *)color { //Create CGFloats to hold our color values CGFloat L, A, B, alpha; //Get LAB values for our color [color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha]; //Find the nearest flat color return [self nearestFlatColorForL:L A:A B:B alpha:1.0]; } //Array of all our colors + (NSArray *)flatColors { return @[FlatBlack, FlatBlackDark, FlatBlue, FlatBlueDark, FlatBrown, FlatBrownDark, FlatCoffee, FlatCoffeeDark, FlatForestGreen, FlatForestGreenDark, FlatGray, FlatGrayDark, FlatGreen, FlatGreenDark, FlatLime, FlatLimeDark, FlatMagenta, FlatMagentaDark, FlatMaroon, FlatMaroonDark, FlatMint, FlatMintDark, FlatNavyBlue, FlatNavyBlueDark, FlatOrange, FlatOrangeDark, FlatPink, FlatPinkDark, FlatPlum, FlatPlumDark, FlatPowderBlue, FlatPowderBlueDark, FlatPurple, FlatPurpleDark, FlatRed, FlatRedDark, FlatSand, FlatSandDark, FlatSkyBlue, FlatSkyBlueDark, FlatTeal, FlatTealDark, FlatWatermelon, FlatWatermelonDark, FlatWhite, FlatWhiteDark, FlatYellow, FlatYellowDark]; } //Calculate the total sum of differences - Euclidian distance //Chameleon is now using the CIEDE2000 formula to calculate distances between 2 colors. //More info: http://en.wikipedia.org/wiki/Color_difference + (float)totalSumOfDifferencesFroml1:(CGFloat)L1 l2:(CGFloat)L2 a1:(CGFloat)A1 a2:(CGFloat)A2 b1:(CGFloat)B1 b2:(CGFloat)B2 { //Get C Values in LCH from LAB Values CGFloat C1 = sqrt(pow(A1, 2) + pow(B1, 2)); CGFloat C2 = sqrt(pow(A2, 2) + pow(B2, 2)); //CIE Weights CGFloat KL = 1; CGFloat KC = 1; CGFloat KH = 1; //Variables specifically set for CIE:2000 CGFloat DeltaPrimeL = L2 - L1; CGFloat MeanL = ((L1 + L2) / 2); CGFloat MeanC = ((C1 + C2) / 2); CGFloat A1Prime = A1 + A1 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); CGFloat A2Prime = A2 + A2 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); CGFloat C1Prime = sqrt(pow(A1Prime, 2) + pow(B1, 2)); CGFloat C2Prime = sqrt(pow(A2Prime, 2) + pow(B2, 2)); CGFloat DeltaPrimeC = C1Prime - C2Prime; CGFloat DeltaC = C1 - C2; CGFloat MeanCPrime = (C1Prime + C2Prime) / 2; CGFloat H1Prime = fmodf(atan2(B1, A1Prime), (360.0 * M_PI/180)); CGFloat H2Prime = fmodf(atan2(B2, A2Prime), (360.0 * M_PI/180)); //Run everything through our △H' Function CGFloat hDeltaPrime = 0; if (fabs(H1Prime - H2Prime) <= (180.0 * M_PI/180)) { hDeltaPrime = H2Prime - H1Prime; } else if (H2Prime <= H1Prime) { hDeltaPrime = (H2Prime - H1Prime) + ((360.0 * M_PI/180)); } else { hDeltaPrime = (H2Prime - H1Prime) - ((360.0 * M_PI/180)); } CGFloat deltaHPrime = 2 * (sqrt(C1Prime*C2Prime)) * sin(hDeltaPrime/2); //Get Mean H' Value CGFloat MeanHPrime = 0; if (fabs(H1Prime-H2Prime) > (180.0 * M_PI/180)) { MeanHPrime = (H1Prime + H2Prime + (360.0 * M_PI/180)) / 2; } else { MeanHPrime = (H1Prime + H2Prime) / 2; } CGFloat T = 1 - 0.17 * cos(MeanHPrime - (30.0 * M_PI/180)) + 0.24 * cos(2 * MeanHPrime)+0.32 * cos(3 * MeanHPrime + (6.0 * M_PI/180)) - 0.20 * cos(4 * MeanHPrime - (63.0 * M_PI/180)); CGFloat SL = 1 + (0.015 * pow((MeanL - 50), 2))/sqrt(20 + pow((MeanL - 50), 2)); CGFloat SC = 1 + 0.045 * MeanCPrime; CGFloat SH = 1 + 0.015 * MeanCPrime * T; CGFloat RT = -2 * sqrt(pow(MeanCPrime, 7) / (pow(MeanCPrime, 7) + pow(25.0, 7))) * sin((60.0 * M_PI/180)* exp(-1 * pow((MeanCPrime - (275.0 * M_PI/180)) / (25.0 * M_PI/180), 2))); //Get total difference CGFloat TotalDifference = sqrt(pow((DeltaPrimeL / (KL * SL)), 2) + pow((DeltaPrimeC / (KC * SC)), 2) + pow((deltaHPrime / (KH * SH)), 2) + RT * (DeltaC / (KC * SC)) * (deltaHPrime / (KH * SH))); return TotalDifference; } + (UIColor *)nearestFlatColorForL:(CGFloat)l1 A:(CGFloat)a1 B:(CGFloat)b1 alpha:(CGFloat)alpha{ //Keep track of our index int index = 0; //Start with a random big number to make sure the first comparison gets saved. float smallestDistance = 1000000; float previousDistance = 1000000; float currentDistance; //Our values CGFloat l2, a2, b2; //We're interested in the color with values returning the smallest sum of total differences so we need to cross reference our input color's values with every flat color's values for (int i=0; i<[[self flatColors] count]; i++ ) { //Check that index is not zero if (i!=0 ) { //Extract LAB values from colors in array and store it as the previous index [[self flatColors][i - 1] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; previousDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 a1:a1 a2:a2 b1:b1 b2:b2]; } //Extract LAB values from colors in array and store it as the current index [[self flatColors][i] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; currentDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 a1:a1 a2:a2 b1:b1 b2:b2]; //We're only interested in the smallest difference if (currentDistance < previousDistance) { if (currentDistance < smallestDistance) { smallestDistance = currentDistance; index = i; } } } //Collect the RGB Values of the color where the smallest difference was found CGFloat red, green, blue; [[self flatColors][index] getRed:&red green:&green blue:&blue alpha:nil]; //Return the closest flat color return rgba(red*255, green*255, blue*255, alpha); } @end @implementation ChameleonCountedColor - (id)initWithColor:(UIColor *)color count:(NSUInteger)count { if ((self = [super init])) { self.color = color; self.count = count; } return self; } - (NSComparisonResult)compare:(ChameleonCountedColor *)object { if ([object isKindOfClass:[ChameleonCountedColor class]]) { if (self.count < object.count) return NSOrderedDescending; else if (self.count == object.count) return NSOrderedSame; } return NSOrderedAscending; } @end ================================================ FILE: Pod/Classes/Objective-C/UIAppearance+Swift.h ================================================ // // UIAppearance+Swift.h // Chameleon // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import @interface UIView (UIViewAppearance_Swift) // @param containers An array of Class < UIAppearanceContainer > // http://stackoverflow.com/a/28765193 + (instancetype)appearanceWhenContainedWithin:(NSArray *)containers; @end ================================================ FILE: Pod/Classes/Objective-C/UIAppearance+Swift.m ================================================ // // UIAppearance+Swift.m // Chameleon // // Created by Vicc Alexander on 11/26/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import "UIAppearance+Swift.h" @implementation UIView (UIViewAppearance_Swift) + (instancetype)appearanceWhenContainedWithin: (NSArray *)containers { NSUInteger count = containers.count; NSAssert(count <= 10, @"The count of containers greater than 10 is not supported."); return [self appearanceWhenContainedIn: count > 0 ? containers[0] : nil, count > 1 ? containers[1] : nil, count > 2 ? containers[2] : nil, count > 3 ? containers[3] : nil, count > 4 ? containers[4] : nil, count > 5 ? containers[5] : nil, count > 6 ? containers[6] : nil, count > 7 ? containers[7] : nil, count > 8 ? containers[8] : nil, count > 9 ? containers[9] : nil, nil]; } @end ================================================ FILE: Pod/Classes/Objective-C/UIButton+Chameleon.h ================================================ // // UIButton+Chameleon.h // Chameleon // // Created by Vicc Alexander on 9/20/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import @interface UIButton (Chameleon) - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR; @end ================================================ FILE: Pod/Classes/Objective-C/UIButton+Chameleon.m ================================================ // // UIButton+Chameleon.m // Chameleon // // Created by Vicc Alexander on 9/20/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import "UIButton+Chameleon.h" @implementation UIButton (Chameleon) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR { self.font = [UIFont fontWithName:name size:self.font.pointSize]; } #pragma GCC diagnostic pop @end ================================================ FILE: Pod/Classes/Objective-C/UIColor+Chameleon.h ================================================ // UIColor+Chameleon.h /* The MIT License (MIT) Copyright (c) 2014-2015 Vicc Alexander. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #import #import NS_ASSUME_NONNULL_BEGIN #pragma mark - Enums /** * Defines the gradient style and direction of the gradient color. * * @since 1.0 */ typedef NS_ENUM (NSUInteger, UIGradientStyle) { /** * Returns a gradual blend between colors originating at the leftmost point of an object's frame, and ending at the rightmost point of the object's frame. * * @since 1.0 */ UIGradientStyleLeftToRight, /** * Returns a gradual blend between colors originating at the center of an object's frame, and ending at all edges of the object's frame. NOTE: Supports a Maximum of 2 Colors. * * @since 1.0 */ UIGradientStyleRadial, /** * Returns a gradual blend between colors originating at the topmost point of an object's frame, and ending at the bottommost point of the object's frame. * * @since 1.0 */ UIGradientStyleTopToBottom, UIGradientStyleDiagonal }; /** * Defines the shade of a any flat color. * * @since 1.0 */ typedef NS_ENUM (NSInteger, UIShadeStyle) { /** * Returns the light shade version of a flat color. * * @since 1.0 */ UIShadeStyleLight, /** * Returns the dark shade version of a flat color. * * @since 1.0 */ UIShadeStyleDark }; @interface UIColor (Chameleon) #pragma mark - Instance Variables /** * Stores an object's UIColor image if the UIColor was created using colorWithPatternImage. * * @since 1.0 */ @property (nonatomic, strong) UIImage *gradientImage; #pragma mark - Quick Shorthand Macros // Quick & Easy Shorthand for RGB x HSB Colors // The reason we don't import our Macro file is to prevent naming conflicts. #define rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a] #define rgb(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0] #define hsba(h,s,b,a) [UIColor colorWithHue:h/360.0f saturation:s/100.0f brightness:b/100.0f alpha:a] #define hsb(h,s,b) [UIColor colorWithHue:h/360.0f saturation:s/100.0f brightness:b/100.0f alpha:1.0] #pragma mark - Light Shades #if UIKIT_DEFINE_AS_PROPERTIES /** * Returns a flat color object whose HSB values are 0.0, 0.0, 0.17 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatBlackColor; /** * Returns a flat color object whose HSB values are 0.62, 0.50, 0.63 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatBlueColor; /** * Returns a flat color object whose HSB values are 0.07, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatBrownColor; /** * Returns a flat color object whose HSB values are 0.07, 0.31, 0.64 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatCoffeeColor; /** * Returns a flat color object whose HSB values are 0.38, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatForestGreenColor; /** * Returns a flat color object whose HSB values are 0.51, 0.10, 0.65 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatGrayColor; /** * Returns a flat color object whose HSB values are 0.40, 0.77, 0.80 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatGreenColor; /** * Returns a flat color object whose HSB values are 0.21, 0.70, 0.78 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatLimeColor; /** * Returns a flat color object whose HSB values are 0.79, 0.51, 0.71 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatMagentaColor; /** * Returns a flat color object whose HSB values are 0.01, 0.65, 0.47 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatMaroonColor; /** * Returns a flat color object whose HSB values are 0.47, 0.86, 0.74 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatMintColor; /** * Returns a flat color object whose HSB values are 0.58, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatNavyBlueColor; /** * Returns a flat color object whose HSB values are 0.08, 0.85, 0.90 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatOrangeColor; /** * Returns a flat color object whose HSB values are 0.90, 0.49, 0.96 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPinkColor; /** * Returns a flat color object whose HSB values are 0.83, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPlumColor; /** * Returns a flat color object whose HSB values are 0.62, 0.24, 0.95 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPowderBlueColor; /** * Returns a flat color object whose HSB values are 0.70, 0.52, 0.77 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPurpleColor; /** * Returns a flat color object whose HSB values are 0.02, 0.74, 0.91 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatRedColor; /** * Returns a flat color object whose HSB values are 0.12, 0.25, 0.94 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatSandColor; /** * Returns a flat color object whose HSB values are 0.57, 0.76, 0.86 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatSkyBlueColor; /** * Returns a flat color object whose HSB values are 0.54, 0.55, 0.51 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatTealColor; /** * Returns a flat color object whose HSB values are 0.99, 0.53, 0.94 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatWatermelonColor; /** * Returns a flat color object whose HSB values are 0.53, 0.02, 0.95 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatWhiteColor; /** * Returns a flat color object whose HSB values are 0.13, 0.99, 1.00 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatYellowColor; #else /** * Returns a flat color object whose HSB values are 0.0, 0.0, 0.17 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatBlackColor; /** * Returns a flat color object whose HSB values are 0.62, 0.50, 0.63 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatBlueColor; /** * Returns a flat color object whose HSB values are 0.07, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatBrownColor; /** * Returns a flat color object whose HSB values are 0.07, 0.31, 0.64 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatCoffeeColor; /** * Returns a flat color object whose HSB values are 0.38, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatForestGreenColor; /** * Returns a flat color object whose HSB values are 0.51, 0.10, 0.65 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatGrayColor; /** * Returns a flat color object whose HSB values are 0.40, 0.77, 0.80 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatGreenColor; /** * Returns a flat color object whose HSB values are 0.21, 0.70, 0.78 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatLimeColor; /** * Returns a flat color object whose HSB values are 0.79, 0.51, 0.71 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatMagentaColor; /** * Returns a flat color object whose HSB values are 0.01, 0.65, 0.47 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatMaroonColor; /** * Returns a flat color object whose HSB values are 0.47, 0.86, 0.74 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatMintColor; /** * Returns a flat color object whose HSB values are 0.58, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatNavyBlueColor; /** * Returns a flat color object whose HSB values are 0.08, 0.85, 0.90 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatOrangeColor; /** * Returns a flat color object whose HSB values are 0.90, 0.49, 0.96 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatPinkColor; /** * Returns a flat color object whose HSB values are 0.83, 0.45, 0.37 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatPlumColor; /** * Returns a flat color object whose HSB values are 0.62, 0.24, 0.95 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatPowderBlueColor; /** * Returns a flat color object whose HSB values are 0.70, 0.52, 0.77 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatPurpleColor; /** * Returns a flat color object whose HSB values are 0.02, 0.74, 0.91 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatRedColor; /** * Returns a flat color object whose HSB values are 0.12, 0.25, 0.94 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatSandColor; /** * Returns a flat color object whose HSB values are 0.57, 0.76, 0.86 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatSkyBlueColor; /** * Returns a flat color object whose HSB values are 0.54, 0.55, 0.51 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatTealColor; /** * Returns a flat color object whose HSB values are 0.99, 0.53, 0.94 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatWatermelonColor; /** * Returns a flat color object whose HSB values are 0.53, 0.02, 0.95 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatWhiteColor; /** * Returns a flat color object whose HSB values are 0.13, 0.99, 1.00 and whose alpha value is 1.0. * * @return A flat UIColor object in the HSB colorspace. */ + (UIColor *)flatYellowColor; #endif #pragma mark - Dark Shades #if UIKIT_DEFINE_AS_PROPERTIES /** * Returns a flat color object whose HSB values are 0.00, 0.00, 0.15 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatBlackDarkColor; /** * Returns a flat color object whose HSB values are 0.62, 0.56, 0.51 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.07, 0.45, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatBrownDarkColor; /** * Returns a flat color object whose HSB values are 0.07, 0.34, 0.56 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatCoffeeDarkColor; /** * Returns a flat color object whose HSB values are 0.38, 0.44, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatForestGreenDarkColor; /** * Returns a flat color object whose HSB values are 0.51, 0.10, 0.55 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatGrayDarkColor; /** * Returns a flat color object whose HSB values are 0.40, 0.78, 0.68 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatGreenDarkColor; /** * Returns a flat color object whose HSB values are 0.21, 0.81, 0.69 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatLimeDarkColor; /** * Returns a flat color object whose HSB values are 0.78, 0.61, 0.68 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatMagentaDarkColor; /** * Returns a flat color object whose HSB values are 0.01, 0.68, 0.40 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatMaroonDarkColor; /** * Returns a flat color object whose HSB values are 0.47, 0.86, 0.63 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatMintDarkColor; /** * Returns a flat color object whose HSB values are 0.58, 0.45, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatNavyBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.07, 1.00, 0.83 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatOrangeDarkColor; /** * Returns a flat color object whose HSB values are 0.91, 0.57, 0.83 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPinkDarkColor; /** * Returns a flat color object whose HSB values are 0.83, 0.46, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPlumDarkColor; /** * Returns a flat color object whose HSB values are 0.62, 0.28, 0.84 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPowderBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.70, 0.56, 0.64 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatPurpleDarkColor; /** * Returns a flat color object whose HSB values are 0.02, 0.78, 0.75 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatRedDarkColor; /** * Returns a flat color object whose HSB values are 0.12, 0.30, 0.84 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatSandDarkColor; /** * Returns a flat color object whose HSB values are 0.57, 0.78, 0.73 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatSkyBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.54, 0.54, 0.45 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatTealDarkColor; /** * Returns a flat color object whose HSB values are 0.99, 0.61, 0.85 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatWatermelonDarkColor; /** * Returns a flat color object whose HSB values are 0.57, 0.05, 0.78 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatWhiteDarkColor; /** * Returns a flat color object whose HSB values are 0.11, 1.00, 1.00 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ @property(class, nonatomic, readonly) UIColor *flatYellowDarkColor; #else /** * Returns a flat color object whose HSB values are 0.00, 0.00, 0.15 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatBlackDarkColor; /** * Returns a flat color object whose HSB values are 0.62, 0.56, 0.51 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.07, 0.45, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatBrownDarkColor; /** * Returns a flat color object whose HSB values are 0.07, 0.34, 0.56 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatCoffeeDarkColor; /** * Returns a flat color object whose HSB values are 0.38, 0.44, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatForestGreenDarkColor; /** * Returns a flat color object whose HSB values are 0.51, 0.10, 0.55 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatGrayDarkColor; /** * Returns a flat color object whose HSB values are 0.40, 0.78, 0.68 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatGreenDarkColor; /** * Returns a flat color object whose HSB values are 0.21, 0.81, 0.69 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatLimeDarkColor; /** * Returns a flat color object whose HSB values are 0.78, 0.61, 0.68 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatMagentaDarkColor; /** * Returns a flat color object whose HSB values are 0.01, 0.68, 0.40 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatMaroonDarkColor; /** * Returns a flat color object whose HSB values are 0.47, 0.86, 0.63 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatMintDarkColor; /** * Returns a flat color object whose HSB values are 0.58, 0.45, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatNavyBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.07, 1.00, 0.83 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatOrangeDarkColor; /** * Returns a flat color object whose HSB values are 0.91, 0.57, 0.83 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatPinkDarkColor; /** * Returns a flat color object whose HSB values are 0.83, 0.46, 0.31 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatPlumDarkColor; /** * Returns a flat color object whose HSB values are 0.62, 0.28, 0.84 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatPowderBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.70, 0.56, 0.64 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatPurpleDarkColor; /** * Returns a flat color object whose HSB values are 0.02, 0.78, 0.75 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatRedDarkColor; /** * Returns a flat color object whose HSB values are 0.12, 0.30, 0.84 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatSandDarkColor; /** * Returns a flat color object whose HSB values are 0.57, 0.78, 0.73 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatSkyBlueDarkColor; /** * Returns a flat color object whose HSB values are 0.54, 0.54, 0.45 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatTealDarkColor; /** * Returns a flat color object whose HSB values are 0.99, 0.61, 0.85 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatWatermelonDarkColor; /** * Returns a flat color object whose HSB values are 0.57, 0.05, 0.78 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatWhiteDarkColor; /** * Returns a flat color object whose HSB values are 0.11, 1.00, 1.00 and whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. */ + (UIColor *)flatYellowDarkColor; #endif #pragma mark - Randomizing Colors #if UIKIT_DEFINE_AS_PROPERTIES /** * Returns a randomly generated flat color object whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 1.0 */ @property(class, nonatomic, readonly) UIColor *randomFlatColor; #else /** * Returns a randomly generated flat color object whose alpha value is 1.0. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 1.0 */ + (UIColor *)randomFlatColor; #endif /** * @author Vicc Alexander * * Returns a randomly generated flat color object NOT found in the specified array. * * @param colors An array specifying which colors NOT to return. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 2.1.0 */ + (UIColor *)colorWithRandomFlatColorExcludingColorsInArray:(NSArray * _Nonnull)colors; /** * @author Vicc Alexander * * Returns a randomly generated color object found in the specified array. * * @param colors An array specifying which colors to return. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 2.1.0 */ + (UIColor * _Nullable)colorWithRandomColorInArray:(NSArray * _Nonnull)colors; /** * Returns a randomly generated flat color object with an alpha value of 1.0 in either a light or dark shade. * * @param shadeStyle Specifies whether the randomly generated flat color should be a light or dark shade. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 1.0 */ + (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle; /** * Returns a randomly generated flat color object in either a light or dark shade. * * @param shadeStyle Specifies whether the randomly generated flat color should be a light or dark shade. * @param alpha The opacity. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 2.0 */ + (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha; #pragma mark - Averaging a Color /** * Returns the average color generated by averaging the colors of a specified image. * * @param image A specified @c UIImage. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 2.0 */ + (UIColor *)colorWithAverageColorFromImage:(UIImage *)image; /** * Returns the average color generated by averaging the colors of a specified image. * * @param image A specified @c UIImage. * @param alpha The opacity. * * @return A flat @c UIColor object in the HSB colorspace. * * @since 2.0 */ + (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha; #pragma mark - Complementary Colors /** * Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. * * @param color The color whose complementary color is being requested. * * @return A flat UIColor object in the HSB colorspace. * * @since 1.0 */ + (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color; /** * Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. * * @param color The color whose complementary color is being requested. * @param alpha The opacity. * * @return A flat UIColor object in the HSB colorspace. * * @since 2.0 */ + (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha; #pragma mark - Contrasting Colors /** * Creates and returns either a black or white color object depending on which contrasts more with a specified color. * * @param backgroundColor The specified color of the contrast color that is being requested. * @param flat Pass YES to return flat color objects. * * @return A UIColor object in the HSB colorspace. * * @since 1.0 */ + (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat; /** * Creates and returns either a black or white color object depending on which contrasts more with a specified color. * * @param backgroundColor The specified color of the contrast color that is being requested. * @param flat Pass YES to return flat color objects. * @param alpha The opacity. * * @return A UIColor object in the HSB colorspace. * * @since 2.0 */ + (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat alpha:(CGFloat)alpha; #pragma mark - Gradient Colors /** * Creates and returns a gradient as a color object with an alpha value of 1.0 * * @param gradientStyle Specifies the style and direction of the gradual blend between colors. * @param frame The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. * @param colors An array of color objects used to create a gradient. * * @return A @c UIColor object using colorWithPattern. * * @since 2.0 */ + (UIColor *)colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray * _Nonnull)colors; #pragma mark - Colors from Hex Strings /** * Creates and returns a @c UIColor object based on the specified hex string. * * @param string The hex string. * * @return A @c UIColor object in the RGB colorspace. * * * @since 2.0 */ + (UIColor * _Nullable)colorWithHexString:(NSString* _Nonnull)string; /** * Creates and returns a @c UIColor object based on the specified hex string. * * @param string The hex string. * @param alpha The opacity. * * @return A @c UIColor object in the RGB colorspace. * * * @since 2.0 */ + (UIColor * _Nullable)colorWithHexString:(NSString * _Nonnull)string withAlpha:(CGFloat)alpha; #pragma mark - Instance Methods /** * Creates and returns a flat color object closest to the specified color in the LAB colorspace. * * @return A flat version of the specified @c UIColor. * * @since 2.0 */ - (UIColor *)flatten; /** * Creates and returns a darker shade of a specified color in the HSB space. * * @param percentage The value with which to darken a specified color. * * @return A @c UIColor object in the HSB space. * * @since 2.0 */ - (UIColor * _Nullable)darkenByPercentage:(CGFloat)percentage; /** * @author Vicc Alexander * * Returns the hex string value for the specified color. * * @return An @NSString object. * * @since 2.1.0 */ - (NSString *)hexValue; /** * Creates and returns a lighter shade of a specified color in the HSB space. * * @param percentage The value with which to lighten a specified color. * * @return A @c UIColor object in the HSB space. * * @since 2.0 */ - (UIColor * _Nullable)lightenByPercentage:(CGFloat)percentage; #pragma mark - Deprecated Methods /** * Creates and returns a flat color object closest to the specified color in the LAB colorspace. * * @param color The specified color of the flat color that is being requested. * * @return A flat UIColor object in the RGB colorspace. * * @since 1.0 */ + (UIColor *)colorWithFlatVersionOf:(UIColor *)color __attribute((deprecated(" Use -flatten: instead (First deprecated in Chameleon 2.0)."))); @end NS_ASSUME_NONNULL_END ================================================ FILE: Pod/Classes/Objective-C/UIColor+Chameleon.m ================================================ // UIColor+Chameleon.m /* The MIT License (MIT) Copyright (c) 2014-2015 Vicc Alexander. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #import "UIColor+Chameleon.h" #import "UIColor+ChameleonPrivate.h" #import "ChameleonMacros.h" #import @implementation UIColor (Chameleon) @dynamic gradientImage; #pragma mark - Chameleon - Getter & Setter Methods for Instance Variables + (void)setGradientImage:(UIImage *)gradientImage { objc_setAssociatedObject(self, @selector(gradientImage), gradientImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } + (UIImage *)gradientImage { return objc_getAssociatedObject(self, @selector(gradientImage)); } #pragma mark - Chameleon - Light Shades + (UIColor *)flatBlackColor { return hsb(0, 0, 17); } + (UIColor *)flatBlueColor { return hsb(224, 50, 63); } + (UIColor *)flatBrownColor { return hsb(24, 45, 37); } + (UIColor *)flatCoffeeColor { return hsb(25, 31, 64); } + (UIColor *)flatForestGreenColor { return hsb(138, 45, 37); } + (UIColor *)flatGrayColor { return hsb(184, 10, 65); } + (UIColor *)flatGreenColor { return hsb(145, 77, 80); } + (UIColor *)flatLimeColor { return hsb(74, 70, 78); } + (UIColor *)flatMagentaColor { return hsb(283, 51, 71); } + (UIColor *)flatMaroonColor { return hsb(5, 65, 47); } + (UIColor *)flatMintColor { return hsb(168, 86, 74); } + (UIColor *)flatNavyBlueColor { return hsb(210, 45, 37); } + (UIColor *)flatOrangeColor { return hsb(28, 85, 90); } + (UIColor *)flatPinkColor { return hsb(324, 49, 96); } + (UIColor *)flatPlumColor { return hsb(300, 45, 37); } + (UIColor *)flatPowderBlueColor { return hsb(222, 24, 95); } + (UIColor *)flatPurpleColor { return hsb(253, 52, 77); } + (UIColor *)flatRedColor { return hsb(6, 74, 91); } + (UIColor *)flatSandColor { return hsb(42, 25, 94); } + (UIColor *)flatSkyBlueColor { return hsb(204, 76, 86); } + (UIColor *)flatTealColor { return hsb(195, 55, 51); } + (UIColor *)flatWatermelonColor { return hsb(356, 53, 94); } + (UIColor *)flatWhiteColor { return hsb(192, 2, 95); } + (UIColor *)flatYellowColor { return hsb(48, 99, 100); } #pragma mark - Chameleon - Dark Shades + (UIColor *)flatBlackDarkColor { return hsb(0, 0, 15); } + (UIColor *)flatBlueDarkColor { return hsb(224, 56, 51); } + (UIColor *)flatBrownDarkColor { return hsb(25, 45, 31); } + (UIColor *)flatCoffeeDarkColor { return hsb(25, 34, 56); } + (UIColor *)flatForestGreenDarkColor { return hsb(135, 44, 31); } + (UIColor *)flatGrayDarkColor { return hsb(184, 10, 55); } + (UIColor *)flatGreenDarkColor { return hsb(145, 78, 68); } + (UIColor *)flatLimeDarkColor { return hsb(74, 81, 69); } + (UIColor *)flatMagentaDarkColor { return hsb(282, 61, 68); } + (UIColor *)flatMaroonDarkColor { return hsb(4, 68, 40); } + (UIColor *)flatMintDarkColor { return hsb(168, 86, 63); } + (UIColor *)flatNavyBlueDarkColor { return hsb(210, 45, 31); } + (UIColor *)flatOrangeDarkColor { return hsb(24, 100, 83); } + (UIColor *)flatPinkDarkColor { return hsb(327, 57, 83); } + (UIColor *)flatPlumDarkColor { return hsb(300, 46, 31); } + (UIColor *)flatPowderBlueDarkColor { return hsb(222, 28, 84); } + (UIColor *)flatPurpleDarkColor { return hsb(253, 56, 64); } + (UIColor *)flatRedDarkColor { return hsb(6, 78, 75); } + (UIColor *)flatSandDarkColor { return hsb(42, 30, 84); } + (UIColor *)flatSkyBlueDarkColor { return hsb(204, 78, 73); } + (UIColor *)flatTealDarkColor { return hsb(196, 54, 45); } + (UIColor *)flatWatermelonDarkColor { return hsb(358, 61, 85); } + (UIColor *)flatWhiteDarkColor { return hsb(204, 5, 78); } + (UIColor *)flatYellowDarkColor { return hsb(40, 100, 100); } #pragma mark - Chameleon - "Color With" Methods + (UIColor *)colorWithAverageColorFromImage:(UIImage *)image { return [self colorWithAverageColorFromImage:image withAlpha:1.0]; } + (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha { //Work within the RGB colorspoace CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); unsigned char rgba[4]; CGContextRef context = CGBitmapContextCreate(rgba, 1, 1, 8, 4, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); //Draw our image down to 1x1 pixels CGContextDrawImage(context, CGRectMake(0, 0, 1, 1), image.CGImage); CGColorSpaceRelease(colorSpace); CGContextRelease(context); //Check if image alpha is 0 if (rgba[3] == 0) { CGFloat imageAlpha = ((CGFloat)rgba[3])/255.0; CGFloat multiplier = imageAlpha/255.0; UIColor *averageColor = [UIColor colorWithRed:((CGFloat)rgba[0])*multiplier green:((CGFloat)rgba[1])*multiplier blue:((CGFloat)rgba[2])*multiplier alpha:imageAlpha]; //Improve color averageColor = [averageColor colorWithMinimumSaturation:0.15]; //Return average color return averageColor; } else { //Get average UIColor *averageColor = [UIColor colorWithRed:((CGFloat)rgba[0])/255.0 green:((CGFloat)rgba[1])/255.0 blue:((CGFloat)rgba[2])/255.0 alpha:alpha]; //Improve color averageColor = [averageColor colorWithMinimumSaturation:0.15]; //Return average color return averageColor; } } + (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color { return [[self class] colorWithComplementaryFlatColorOf:color withAlpha:1.0]; } + (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha { //Check if input UIColor is a gradient aka a pattern if (CGColorGetPattern(color.CGColor)) { //Let's find the average color of the image and contrast against that. CGSize size = {1, 1}; //Create a 1x1 bitmap context UIGraphicsBeginImageContext(size); CGContextRef ctx = UIGraphicsGetCurrentContext(); //Set the interpolation quality to medium CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); //Draw image scaled down to this 1x1 pixel [[self gradientImage] drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; //Read the RGB values from the context's buffer uint8_t *data = CGBitmapContextGetData(ctx); color = [UIColor colorWithRed:data[2] / 255.0f green:data[1] / 255.0f blue:data[0] / 255.0f alpha:1]; UIGraphicsEndImageContext(); } //Extract & Check to make sure we have an actual color to work with (Clear returns clear) CGFloat hue, saturation, brightness, alpha1; [color getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha1]; //Check if color is transparent if (alpha1 == 0) { return [UIColor clearColor]; } //Multiply our value by their max values to convert hue *= 360; saturation *= 100; brightness *= 100; //Select a color with a hue 180 degrees away on the colorwheel (i.e. for 50 it would be 230). hue += 180.0f; if (hue > 360.f) { hue -= 360.0f; } //Round to the nearest whole number after multiplying hue = roundf(hue); saturation = roundf(saturation); brightness = roundf(brightness); //Store complimentary nonflat color UIColor *complimentaryNonFlatColor = [UIColor colorWithHue:hue/360.0 saturation:saturation/100.0 brightness:brightness/100.0 alpha:alpha]; //Retrieve LAB values from our complimentary nonflat color & return nearest flat color return [self colorWithFlatVersionOf:complimentaryNonFlatColor withAlpha:alpha]; } + (UIColor *)colorWithFlatVersionOf:(UIColor *)color { //Return flat version with default alpha of 1.0 return [[self class] colorWithFlatVersionOf:color withAlpha:1.0]; } + (UIColor *)colorWithFlatVersionFrom:(UIColor *)color { CGFloat colorAlpha = 0; [color getLightness:nil valueForA:nil valueForB:nil alpha:&colorAlpha]; colorAlpha = colorAlpha > 0.0 ? colorAlpha : 1.0; //Return flat version with default alpha of 1.0 return [[self class] colorWithFlatVersionOf:color withAlpha:colorAlpha]; } + (UIColor * _Nullable)colorWithFlatVersionOf:(UIColor *)color withAlpha:(CGFloat)alpha { //Check if input UIColor is a gradient aka a pattern if (CGColorGetPattern(color.CGColor)) { //Let's find the average color of the image and contrast against that. CGSize size = {1, 1}; //Create a 1x1 bitmap context UIGraphicsBeginImageContext(size); CGContextRef ctx = UIGraphicsGetCurrentContext(); //Set the interpolation quality to medium CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); //Draw image scaled down to this 1x1 pixel [[self gradientImage] drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; //Read the RGB values from the context's buffer uint8_t *data = CGBitmapContextGetData(ctx); color = [UIColor colorWithRed:data[2] / 255.0f green:data[1] / 255.0f blue:data[0] / 255.0f alpha:1]; UIGraphicsEndImageContext(); } //Create CGFloats to hold our color values CGFloat L, A, B, alpha1; //Get LAB values for our color [color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha1]; if (![color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha1]) { return nil; } //Find the nearest flat color return [self nearestFlatColorForL:L A:A B:B alpha:alpha]; } + (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat { //Return color with default alpha value of 1.0 return [[self class] colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:flat alpha:1.0]; } + (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat alpha:(CGFloat)alpha { //Check if UIColor is a gradient aka a pattern if (CGColorGetPattern(backgroundColor.CGColor)) { //Let's find the average color of the image and contrast against that. CGSize size = {1, 1}; //Create a 1x1 bitmap context UIGraphicsBeginImageContext(size); CGContextRef ctx = UIGraphicsGetCurrentContext(); //Set the interpolation quality to medium CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); //Draw image scaled down to this 1x1 pixel [[self gradientImage] drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; //Read the RGB values from the context's buffer uint8_t *data = CGBitmapContextGetData(ctx); backgroundColor = [UIColor colorWithRed:data[2] / 255.0f green:data[1] / 255.0f blue:data[0] / 255.0f alpha:1]; UIGraphicsEndImageContext(); } //Calculate Luminance CGFloat luminance; CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha1 = 0.0; [backgroundColor getRed:&red green:&green blue:&blue alpha:&alpha1]; //Check if color is transparent if (alpha == 0) { return [UIColor clearColor]; } // Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; luminance = red + green + blue; if (flat == NO) { return (luminance > 0.6f) ? rgba(0, 0, 0, alpha) : rgba(255, 255, 255, alpha); } else { return (luminance > 0.6f) ? hsba(0, 0, 15, alpha) : hsba(192, 2, 95, alpha); } } + (UIColor *)colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray * _Nonnull)colors; { //Create our background gradient layer CAGradientLayer *backgroundGradientLayer = [CAGradientLayer layer]; //Set the frame to our object's bounds backgroundGradientLayer.frame = frame; //To simplfy formatting, we'll iterate through our colors array and create a mutable array with their CG counterparts NSMutableArray *cgColors = [[NSMutableArray alloc] init]; for (UIColor *color in colors) { [cgColors addObject:(id)[color CGColor]]; } switch (gradientStyle) { case UIGradientStyleLeftToRight: { //Set out gradient's colors backgroundGradientLayer.colors = cgColors; //Specify the direction our gradient will take [backgroundGradientLayer setStartPoint:CGPointMake(0.0, 0.5)]; [backgroundGradientLayer setEndPoint:CGPointMake(1.0, 0.5)]; //Convert our CALayer to a UIImage object UIGraphicsBeginImageContextWithOptions(backgroundGradientLayer.bounds.size,NO, [UIScreen mainScreen].scale); [backgroundGradientLayer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self setGradientImage:backgroundColorImage]; return [UIColor colorWithPatternImage:backgroundColorImage]; } case UIGradientStyleRadial: { UIGraphicsBeginImageContextWithOptions(frame.size,NO, [UIScreen mainScreen].scale); //Specific the spread of the gradient (For now this gradient only takes 2 locations) CGFloat locations[2] = {0.0, 1.0}; //Default to the RGB Colorspace CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB(); CFArrayRef arrayRef = (__bridge CFArrayRef)cgColors; //Create our Fradient CGGradientRef myGradient = CGGradientCreateWithColors(myColorspace, arrayRef, locations); // Normalise the 0-1 ranged inputs to the width of the image CGPoint myCentrePoint = CGPointMake(0.5 * frame.size.width, 0.5 * frame.size.height); float myRadius = MIN(frame.size.width, frame.size.height) * 0.5; // Draw our Gradient CGContextDrawRadialGradient (UIGraphicsGetCurrentContext(), myGradient, myCentrePoint, 0, myCentrePoint, myRadius, kCGGradientDrawsAfterEndLocation); // Grab it as an Image UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); // Clean up CGColorSpaceRelease(myColorspace); // Necessary? CGGradientRelease(myGradient); // Necessary? UIGraphicsEndImageContext(); [self setGradientImage:backgroundColorImage]; return [UIColor colorWithPatternImage:backgroundColorImage]; } case UIGradientStyleDiagonal: { //Set out gradient's colors backgroundGradientLayer.colors = cgColors; //Specify the direction our gradient will take [backgroundGradientLayer setStartPoint:CGPointMake(0.0, 1.0)]; [backgroundGradientLayer setEndPoint:CGPointMake(1.0, 0.0)]; //Convert our CALayer to a UIImage object UIGraphicsBeginImageContextWithOptions(backgroundGradientLayer.bounds.size,NO, [UIScreen mainScreen].scale); [backgroundGradientLayer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self setGradientImage:backgroundColorImage]; return [UIColor colorWithPatternImage:backgroundColorImage]; } case UIGradientStyleTopToBottom: default: { //Set out gradient's colors backgroundGradientLayer.colors = cgColors; //Convert our CALayer to a UIImage object UIGraphicsBeginImageContextWithOptions(backgroundGradientLayer.bounds.size,NO, [UIScreen mainScreen].scale); [backgroundGradientLayer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self setGradientImage:backgroundColorImage]; return [UIColor colorWithPatternImage:backgroundColorImage]; } } } + (UIColor * _Nullable)colorWithHexString:(NSString * _Nonnull)string { //Color with string and a defualt alpha value of 1.0 return [self colorWithHexString:string withAlpha:1.0]; } + (UIColor * _Nullable)colorWithHexString:(NSString * _Nonnull)string withAlpha:(CGFloat)alpha { //Quick return in case string is empty if (string.length == 0) { return nil; } //Check to see if we need to add a hashtag if('#' != [string characterAtIndex:0]) { string = [NSString stringWithFormat:@"#%@", string]; } //Make sure we have a working string length if (string.length != 7 && string.length != 4) { #ifdef DEBUG NSLog(@"Unsupported string format: %@", string); #endif return nil; } //Check for short hex strings if(string.length == 4) { //Convert to full length hex string string = [NSString stringWithFormat:@"#%@%@%@%@%@%@", [string substringWithRange:NSMakeRange(1, 1)],[string substringWithRange:NSMakeRange(1, 1)], [string substringWithRange:NSMakeRange(2, 1)],[string substringWithRange:NSMakeRange(2, 1)], [string substringWithRange:NSMakeRange(3, 1)],[string substringWithRange:NSMakeRange(3, 1)]]; } NSString *redHex = [NSString stringWithFormat:@"0x%@", [string substringWithRange:NSMakeRange(1, 2)]]; unsigned red = [[self class] hexValueToUnsigned:redHex]; NSString *greenHex = [NSString stringWithFormat:@"0x%@", [string substringWithRange:NSMakeRange(3, 2)]]; unsigned green = [[self class] hexValueToUnsigned:greenHex]; NSString *blueHex = [NSString stringWithFormat:@"0x%@", [string substringWithRange:NSMakeRange(5, 2)]]; unsigned blue = [[self class] hexValueToUnsigned:blueHex]; return [UIColor colorWithRed:(float)red/255 green:(float)green/255 blue:(float)blue/255 alpha:alpha]; } + (unsigned)hexValueToUnsigned:(NSString *)hexValue { //Define default unsigned value unsigned value = 0; //Scan unsigned value NSScanner *hexValueScanner = [NSScanner scannerWithString:hexValue]; [hexValueScanner scanHexInt:&value]; //Return found value return value; } #pragma mark - Chameleon - Random Color Methods + (NSInteger)generateRandomNumberWithMax:(NSInteger)max { //Choose a random number between 0 and our number of available colors return arc4random_uniform((UInt32)max); } + (UIColor *)randomFlatColor { //Number of colors to choose from const uint32_t numberOfPossibleColors = 48; //Chose one of those colors at random NSInteger randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; //Check if a previous random number exists if (![[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { //If no previous number exists, save it as such and find the matching color [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; [[NSUserDefaults standardUserDefaults] synchronize]; } else { //Keep generating a random number until it is different than the one generated last time while (randomColorChosen == [[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; } //Once a new number has been generated then store it as the previous number for next time and proceed [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; [[NSUserDefaults standardUserDefaults] synchronize]; } return [self flatColors][randomColorChosen]; } + (UIColor * _Nullable)colorWithRandomColorInArray:(NSArray *)colors { UIColor *randomColor; if (colors.count) { //Pick a random index NSInteger randomIndex = arc4random() % colors.count; //Return the color at the random index randomColor = colors[randomIndex]; } else { return nil; } NSAssert([randomColor isKindOfClass:[UIColor class]], @"Hmm... one of your objects in your 'colors' array is not a UIColor object."); //Return return randomColor; } + (UIColor *)colorWithRandomFlatColorExcludingColorsInArray:(NSArray *)colors { //Set random flat color UIColor *randomColor = [[self class] randomFlatColor]; //If the selected color is blacklisted select a new color while ([colors containsObject:randomColor]) { randomColor = [[self class] randomFlatColor]; } //Return return randomColor; } + (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle { //Return color with default alpha value of 1.0 return [[self class] colorWithRandomFlatColorOfShadeStyle:shadeStyle withAlpha:1.0]; } + (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha { //Number of colors to choose from const NSInteger numberOfPossibleColors = 24; //Chose one of those colors at random NSInteger randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; //Check if a previous random number exists if (![[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { //If no previous number exists, save it as such and find the matching color [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; [[NSUserDefaults standardUserDefaults] synchronize]; } else { //Keep generating a random number until it is different than the one generated last time while (randomColorChosen == [[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; } //Once a new number has been generated then store it as the previous number for next time and proceed [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; [[NSUserDefaults standardUserDefaults] synchronize]; } //Assign a random color based on randomColorChosen UIColor *randomColor; //Return a color depending on the specified shade switch (shadeStyle) { case UIShadeStyleDark: { NSArray *darkColors = @[FlatBlackDark, FlatBlueDark, FlatBrownDark, FlatCoffeeDark, FlatForestGreenDark, FlatGrayDark, FlatGreenDark, FlatLimeDark, FlatMagentaDark, FlatMaroonDark, FlatMintDark, FlatNavyBlueDark, FlatOrangeDark, FlatPinkDark, FlatPlumDark, FlatPowderBlueDark, FlatPurpleDark, FlatRedDark, FlatSandDark, FlatSkyBlueDark, FlatTealDark, FlatWatermelonDark, FlatWhiteDark, FlatYellowDark]; randomColor = darkColors[randomColorChosen]; break; } case UIShadeStyleLight: default: { NSArray *lightColors = @[FlatBlack, FlatBlue, FlatBrown, FlatCoffee, FlatForestGreen, FlatGray, FlatGreen, FlatLime, FlatMagenta, FlatMaroon, FlatMint, FlatNavyBlue, FlatOrange, FlatPink, FlatPlum, FlatPowderBlue, FlatPurple, FlatRed, FlatSand, FlatSkyBlue, FlatTeal, FlatWatermelon, FlatWhite, FlatYellow]; randomColor = lightColors[randomColorChosen]; break; } } //Return color with correct alpha value randomColor = [randomColor colorWithAlphaComponent:alpha]; return randomColor; } #pragma mark - Chameleon Instance Methods - (UIColor *)flatten { return [UIColor colorWithFlatVersionFrom:self]; } - (NSString *)hexValue { UIColor *currentColor = self; if (CGColorGetNumberOfComponents(self.CGColor) < 4) { const CGFloat *components = CGColorGetComponents(self.CGColor); currentColor = [UIColor colorWithRed:components[0] green:components[0] blue:components[0] alpha:components[1]]; } if (CGColorSpaceGetModel(CGColorGetColorSpace(currentColor.CGColor)) != kCGColorSpaceModelRGB) { return [NSString stringWithFormat:@"#FFFFFF"]; } return [NSString stringWithFormat:@"#%02X%02X%02X", (int)((CGColorGetComponents(currentColor.CGColor))[0]*255.0), (int)((CGColorGetComponents(currentColor.CGColor))[1]*255.0), (int)((CGColorGetComponents(currentColor.CGColor))[2]*255.0)]; } - (UIColor * _Nullable)darkenByPercentage:(CGFloat)percentage { //Define HSBA values CGFloat h, s, b, a; //Check if HSBA values exist if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) { //Make sure our percentage is greater than 0 if (percentage > 0) { b = MIN(b - percentage, 1.0); } //Return darker color return [UIColor colorWithHue:h saturation:s brightness:b alpha:a]; } return nil; } - (UIColor * _Nullable)lightenByPercentage:(CGFloat)percentage { //Define HSBA values CGFloat h, s, b, a; //Check if HSBA values exist if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) { //Make sure our percentage is greater than 0 if (percentage > 0) { b = MIN(b + percentage, 1.0); } //Return lighter color return [UIColor colorWithHue:h saturation:s brightness:b alpha:a]; } return nil; } - (UIColor * _Nullable)desaturateByPercentage:(CGFloat)percentage { //Define HSBA values CGFloat h, s, b, a; //Check if HSBA values exist if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) { //Make sure our percentage is greater than 0 if (percentage > 0) { s = MIN(s - percentage, 1.0); } //Return darker color return [UIColor colorWithHue:h saturation:s brightness:b alpha:a]; } return nil; } - (UIColor * _Nullable)saturateByPercentage:(CGFloat)percentage { //Define HSBA values CGFloat h, s, b, a; //Check if HSBA values exist if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) { //Make sure our percentage is greater than 0 if (percentage > 0) { s = MIN(s + percentage, 1.0); } //Return lighter color return [UIColor colorWithHue:h saturation:s brightness:b alpha:a]; } return nil; } - (BOOL)isEqualToColor:(UIColor *)color { //Check if both colors are in the Monochrome / RGB color space if ([self isMonochromeOrRGB] && [color isMonochromeOrRGB]) { //Return comparison return self.RGBAValue == color.RGBAValue; } //Return comparison return [self isEqual:color]; } #pragma mark - Chameleon Internal Methods //Array of all our colors + (NSArray *)flatColors { return @[FlatBlack, FlatBlackDark, FlatBlue, FlatBlueDark, FlatBrown, FlatBrownDark, FlatCoffee, FlatCoffeeDark, FlatForestGreen, FlatForestGreenDark, FlatGray, FlatGrayDark, FlatGreen, FlatGreenDark, FlatLime, FlatLimeDark, FlatMagenta, FlatMagentaDark, FlatMaroon, FlatMaroonDark, FlatMint, FlatMintDark, FlatNavyBlue, FlatNavyBlueDark, FlatOrange, FlatOrangeDark, FlatPink, FlatPinkDark, FlatPlum, FlatPlumDark, FlatPowderBlue, FlatPowderBlueDark, FlatPurple, FlatPurpleDark, FlatRed, FlatRedDark, FlatSand, FlatSandDark, FlatSkyBlue, FlatSkyBlueDark, FlatTeal, FlatTealDark, FlatWatermelon, FlatWatermelonDark, FlatWhite, FlatWhiteDark, FlatYellow, FlatYellowDark]; } - (uint32_t)RGBAValue { CGFloat rgba[4]; [self getRGBAComponents:rgba]; uint8_t red = rgba[0]*255; uint8_t green = rgba[1]*255; uint8_t blue = rgba[2]*255; uint8_t alpha = rgba[3]*255; return (red << 24) + (green << 16) + (blue << 8) + alpha; } - (void)getRGBAComponents:(CGFloat[4])rgba { CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor)); const CGFloat *components = CGColorGetComponents(self.CGColor); switch (model) { case kCGColorSpaceModelMonochrome: { rgba[0] = components[0]; rgba[1] = components[0]; rgba[2] = components[0]; rgba[3] = components[1]; break; } case kCGColorSpaceModelRGB: { rgba[0] = components[0]; rgba[1] = components[1]; rgba[2] = components[2]; rgba[3] = components[3]; break; } case kCGColorSpaceModelCMYK: case kCGColorSpaceModelDeviceN: case kCGColorSpaceModelIndexed: case kCGColorSpaceModelLab: case kCGColorSpaceModelPattern: case kCGColorSpaceModelUnknown: { #ifdef DEBUG NSLog(@"Unsupported color model: %i", model); #endif rgba[0] = 0.0f; rgba[1] = 0.0f; rgba[2] = 0.0f; rgba[3] = 1.0f; break; } } } //Check if color is in the monochrome or rgb color space - (BOOL)isMonochromeOrRGB { CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor)); return model == kCGColorSpaceModelMonochrome || model == kCGColorSpaceModelRGB; } //Calculate the total sum of differences - Euclidian distance //Chameleon is now using the CIEDE2000 formula to calculate distances between 2 colors. //More info: http://en.wikipedia.org/wiki/Color_difference + (float)totalSumOfDifferencesFroml1:(CGFloat)L1 l2:(CGFloat)L2 a1:(CGFloat)A1 a2:(CGFloat)A2 b1:(CGFloat)B1 b2:(CGFloat)B2 { //Get C Values in LCH from LAB Values CGFloat C1 = sqrt(pow(A1, 2) + pow(B1, 2)); CGFloat C2 = sqrt(pow(A2, 2) + pow(B2, 2)); //CIE Weights CGFloat KL = 1; CGFloat KC = 1; CGFloat KH = 1; //Variables specifically set for CIE:2000 CGFloat DeltaPrimeL = L2 - L1; CGFloat MeanL = ((L1 + L2) / 2); CGFloat MeanC = ((C1 + C2) / 2); CGFloat A1Prime = A1 + A1 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); CGFloat A2Prime = A2 + A2 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); CGFloat C1Prime = sqrt(pow(A1Prime, 2) + pow(B1, 2)); CGFloat C2Prime = sqrt(pow(A2Prime, 2) + pow(B2, 2)); CGFloat DeltaPrimeC = C1Prime - C2Prime; CGFloat DeltaC = C1 - C2; CGFloat MeanCPrime = (C1Prime + C2Prime) / 2; CGFloat H1Prime = fmodf(atan2(B1, A1Prime), (360.0 * M_PI/180)); CGFloat H2Prime = fmodf(atan2(B2, A2Prime), (360.0 * M_PI/180)); //Run everything through our △H' Function CGFloat hDeltaPrime = 0; if (fabs(H1Prime - H2Prime) <= (180.0 * M_PI/180)) { hDeltaPrime = H2Prime - H1Prime; } else if (H2Prime <= H1Prime) { hDeltaPrime = (H2Prime - H1Prime) + ((360.0 * M_PI/180)); } else { hDeltaPrime = (H2Prime - H1Prime) - ((360.0 * M_PI/180)); } CGFloat deltaHPrime = 2 * (sqrt(C1Prime*C2Prime)) * sin(hDeltaPrime/2); //Get Mean H' Value CGFloat MeanHPrime = 0; if (fabs(H1Prime-H2Prime) > (180.0 * M_PI/180)) { MeanHPrime = (H1Prime + H2Prime + (360.0 * M_PI/180)) / 2; } else { MeanHPrime = (H1Prime + H2Prime) / 2; } CGFloat T = 1 - 0.17 * cos(MeanHPrime - (30.0 * M_PI/180)) + 0.24 * cos(2 * MeanHPrime)+0.32 * cos(3 * MeanHPrime + (6.0 * M_PI/180)) - 0.20 * cos(4 * MeanHPrime - (63.0 * M_PI/180)); CGFloat SL = 1 + (0.015 * pow((MeanL - 50), 2))/sqrt(20 + pow((MeanL - 50), 2)); CGFloat SC = 1 + 0.045 * MeanCPrime; CGFloat SH = 1 + 0.015 * MeanCPrime * T; CGFloat RT = -2 * sqrt(pow(MeanCPrime, 7) / (pow(MeanCPrime, 7) + pow(25.0, 7))) * sin((60.0 * M_PI/180)* exp(-1 * pow((MeanCPrime - (275.0 * M_PI/180)) / (25.0 * M_PI/180), 2))); //Get total difference CGFloat TotalDifference = sqrt(pow((DeltaPrimeL / (KL * SL)), 2) + pow((DeltaPrimeC / (KC * SC)), 2) + pow((deltaHPrime / (KH * SH)), 2) + RT * (DeltaC / (KC * SC)) * (deltaHPrime / (KH * SH))); return TotalDifference; } + (UIColor *)nearestFlatColorForL:(CGFloat)l1 A:(CGFloat)a1 B:(CGFloat)b1 alpha:(CGFloat)alpha{ //Keep track of our index int index = 0; //Start with a random big number to make sure the first comparison gets saved. float smallestDistance = 1000000; float previousDistance = 1000000; float currentDistance; //Our values CGFloat l2, a2, b2; //We're interested in the color with values returning the smallest sum of total differences so we need to cross reference our input color's values with every flat color's values for (int i=0; i<[[self flatColors] count]; i++ ) { //Check that index is not zero if (i!=0 ) { //Extract LAB values from colors in array and store it as the previous index [[self flatColors][i - 1] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; previousDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 a1:a1 a2:a2 b1:b1 b2:b2]; } //Extract LAB values from colors in array and store it as the current index [[self flatColors][i] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; currentDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 a1:a1 a2:a2 b1:b1 b2:b2]; //We're only interested in the smallest difference if (currentDistance < previousDistance) { if (currentDistance < smallestDistance) { smallestDistance = currentDistance; index = i; } } } //Collect the RGB Values of the color where the smallest difference was found CGFloat red, green, blue; [[self flatColors][index] getRed:&red green:&green blue:&blue alpha:nil]; //Return the closest flat color return rgba(red * 255, green * 255, blue * 255, alpha); } @end ================================================ FILE: Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h ================================================ // // UIColor+ChameleonPrivate.h // Chameleon // // Created by Vicc Alexander on 6/6/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import #import @interface UIColor (ChameleonPrivate) @property (nonatomic, readwrite) NSUInteger count; #pragma mark - Class Methods + (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point; - (UIColor *)colorWithMinimumSaturation:(CGFloat)saturation; #pragma mark - Instance Methods - (BOOL)isDistinct:(UIColor *)color; - (BOOL)getValueForX:(CGFloat *)X valueForY:(CGFloat *)Y valueForZ:(CGFloat *)Z alpha:(CGFloat *)alpha; - (BOOL)getLightness:(CGFloat *)L valueForA:(CGFloat *)A valueForB:(CGFloat *)B alpha:(CGFloat *)alpha; @end ================================================ FILE: Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m ================================================ // // UIColor+ChameleonPrivate.m // Chameleon // // Created by Vicc Alexander on 6/6/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "UIColor+ChameleonPrivate.h" @implementation UIColor (ChameleonPrivate) @dynamic count; #pragma mark - Associated Objects Methods - (void)setCount:(NSUInteger)count { objc_setAssociatedObject(self, @selector(count), [NSNumber numberWithUnsignedInteger:count], OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (NSUInteger)count { NSNumber *number = objc_getAssociatedObject(self, @selector(count)); return [number unsignedIntegerValue]; } #pragma mark - Class Methods // Would not have been possible without - http://stackoverflow.com/a/1262893 + (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point { //Encapsulate our image CGImageRef imageRef = image.CGImage; NSUInteger width = CGImageGetWidth(imageRef); NSUInteger height = CGImageGetHeight(imageRef); //Specify the colorspace we're in CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); //Extract the data we need unsigned char *rawData = calloc(height * width * 4, sizeof(unsigned char)); NSUInteger bytesPerPixel = 4; NSUInteger bytesPerRow = bytesPerPixel * width; NSUInteger bitsPerComponent = 8; CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); //Release colorspace CGColorSpaceRelease(colorSpace); //Draw and release image CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); CGContextRelease(context); //rawData now contains the image data in RGBA8888 NSInteger byteIndex = (bytesPerRow * point.y) + (point.x * bytesPerPixel); //Define our RGBA values CGFloat red = (rawData[byteIndex] * 1.f) / 255.f; CGFloat green = (rawData[byteIndex + 1] * 1.f) / 255.f; CGFloat blue = (rawData[byteIndex + 2] * 1.f) / 255.f; CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.f; //Free our rawData free(rawData); //Return color return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } - (UIColor *)colorWithMinimumSaturation:(CGFloat)saturation { if (!self) return nil; CGFloat h, s, b, a; [self getHue:&h saturation:&s brightness:&b alpha:&a]; if (s < saturation) return [UIColor colorWithHue:h saturation:saturation brightness:b alpha:a]; return self; } #pragma mark - Instance Methods - (BOOL)isDistinct:(UIColor *)color { if (!self || !color) { return NO; } CGFloat r, g, b, a; CGFloat rc, gc, bc, ac; [self getRed:&r green:&g blue:&b alpha:&a]; [color getRed:&rc green:&gc blue:&bc alpha:&ac]; CGFloat threshold = 0.25f; if (fabs(r - rc) > threshold || fabs(g - gc) > threshold || fabs(b - bc) > threshold || fabs(a - ac) > threshold) { // Check for grays if (fabs(r - g) < 0.03f && fabs(r - b) < 0.03f) { if (fabs(rc - gc) < 0.03f && (fabs(rc - bc) < 0.03f)) { return NO; } } return YES; } return NO; } - (BOOL)getValueForX:(CGFloat *)X valueForY:(CGFloat *)Y valueForZ:(CGFloat *)Z alpha:(CGFloat *)alpha{ if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) { //Get RGB values from the input color CGFloat red = 0, green = 0, blue = 0, alpha1 = 0; [self getRed:&red green:&green blue:&blue alpha:&alpha1]; //Run our input color's RGB values through the XYZ algorithm to convert them into XYZ values NSArray *XYZValues = [self arrayOfXYZValuesForR:red G:green B:blue A:alpha1]; *X = [XYZValues[0] floatValue]; *Y = [XYZValues[1] floatValue]; *Z = [XYZValues[2] floatValue]; *alpha = [XYZValues[3] floatValue]; return YES; } return NO; } - (BOOL)getLightness:(CGFloat *)L valueForA:(CGFloat *)A valueForB:(CGFloat *)B alpha:(CGFloat *)alpha { if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) { //Get RGB values from the input color CGFloat red = 0, green = 0, blue = 0, alpha1 = 0; [self getRed:&red green:&green blue:&blue alpha:&alpha1]; //Run our input color's RGB values through the XYZ algorithm to convert them into XYZ values NSArray *XYZValues = [self arrayOfXYZValuesForR:red G:green B:blue A:alpha1]; CGFloat X = [XYZValues[0] floatValue]; CGFloat Y = [XYZValues[1] floatValue]; CGFloat Z = [XYZValues[2] floatValue]; if (L != nil && A != nil && B != nil) { //Run our new XYZ values through our LAB algorithm to convert them into LAB values NSArray *LABValues = [self arrayOfLABValuesForX:X Y:Y Z:Z alpha:alpha1]; *L = [LABValues[0] floatValue]; *A = [LABValues[1] floatValue]; *B = [LABValues[2] floatValue]; } return YES; } return NO; } #pragma mark - Internal Helper Methods - (NSArray *)arrayOfXYZValuesForR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha { /* Let's begin by converting from RGB to sRGB. We're going to use the Reverse Transformation Equation. http://en.wikipedia.org/wiki/SRGB */ void (^sRGB)(CGFloat *C); sRGB = ^(CGFloat *C) { if (*C > 0.04045) { *C = pow(((*C + 0.055)/ (1 + 0.055)), 2.40); } else { *C /= 12.92; } }; sRGB(&red); sRGB(&green); sRGB(&blue); /* Now we're going to convert to XYZ values, using a matrix multiplication of the linear values http://upload.wikimedia.org/math/4/3/3/433376fc18cccd887758beffb7e7c625.png */ CGFloat X = (red * 0.4124) + (green * 0.3576) + (blue * 0.1805); CGFloat Y = (red * 0.2126) + (green * 0.7152) + (blue * 0.0722); CGFloat Z = (red * 0.0193) + (green * 0.1192) + (blue * 0.9505); X *= 100; Y *= 100; Z *= 100; return @[@(X), @(Y), @(Z), @(alpha)]; } - (NSArray *)arrayOfLABValuesForX:(CGFloat)X Y:(CGFloat)Y Z:(CGFloat)Z alpha:(CGFloat)alpha { /* The corresponding original XYZ values are such that white is D65 with unit luminance (X,Y,Z = 0.9505, 1.0000, 1.0890). Calculations are also to assume the 2° standard colorimetric observer. D65: http://en.wikipedia.org/wiki/CIE_Standard_Illuminant_D65 Standard Colorimetric Observer: http://en.wikipedia.org/wiki/Standard_colorimetric_observer#CIE_standard_observer Since we mutiplied our XYZ values by 100 to produce a percentage we should also multiply our unit luminance values by 100. */ X /= (0.9505 * 100); Y /= (1.0000 * 100); Z /= (1.0890 * 100); /* Next we need to use the forward transformation function for CIELAB-CIEXYZ conversions Function: http://upload.wikimedia.org/math/e/5/1/e513d25d50d406bfffb6ed3c854bd8a4.png */ void (^XYZtoLAB)(CGFloat *f); XYZtoLAB = ^(CGFloat *f) { if ((*f > pow((6.0/29.0), 3.0)) ) { *f = pow(*f, 1.0/3.0); } else { *f = (1/3)*pow((29.0/6.0), 2.0) * *f + 4/29.0; } }; XYZtoLAB(&X); XYZtoLAB(&Y); XYZtoLAB(&Z); /* Next we get our LAB values using the following equations and the results from the function above http://upload.wikimedia.org/math/0/0/6/006164b74314e2fdcdc34ac9d0aa6fe4.png */ CGFloat L = (116 * Y) - 16; CGFloat A = 500 * (X - Y); CGFloat B = 200 * (Y - Z); return @[@(L), @(A), @(B), @(alpha)]; } @end ================================================ FILE: Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h ================================================ // // UIImage+ChameleonPrivate.h // Chameleon // // Created by Vicc Alexander on 6/8/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import @interface UIImage (ChameleonPrivate) #pragma mark - Class Methods + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize; #pragma mark - Instance Methods - (UIImage *)imageScaledToSize:(CGSize)newSize; @end ================================================ FILE: Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m ================================================ // // UIImage+ChameleonPrivate.m // Chameleon // // Created by Vicc Alexander on 6/8/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "UIImage+ChameleonPrivate.h" @implementation UIImage (ChameleonPrivate) // Would not have been possible without - http://stackoverflow.com/a/1262893 + (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point { //Encapsulate our image CGImageRef imageRef = image.CGImage; NSUInteger width = CGImageGetWidth(imageRef); NSUInteger height = CGImageGetHeight(imageRef); //Specify the colorspace we're in CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); //Extract the data we need unsigned char *rawData = calloc(height * width * 4, sizeof(unsigned char)); NSUInteger bytesPerPixel = 4; NSUInteger bytesPerRow = bytesPerPixel * width; NSUInteger bitsPerComponent = 8; CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); //Release colorspace CGColorSpaceRelease(colorSpace); //Draw and release image CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); CGContextRelease(context); //rawData now contains the image data in RGBA8888 NSInteger byteIndex = (bytesPerRow * point.y) + (point.x * bytesPerPixel); //Define our RGBA values CGFloat red = (rawData[byteIndex] * 1.f) / 255.f; CGFloat green = (rawData[byteIndex + 1] * 1.f) / 255.f; CGFloat blue = (rawData[byteIndex + 2] * 1.f) / 255.f; CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.f; //Free our rawData free(rawData); //Return color return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize { UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0); [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } #pragma mark - Instance Methods - (UIImage *)imageScaledToSize:(CGSize)newSize { UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0); [self drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } @end ================================================ FILE: Pod/Classes/Objective-C/UILabel+Chameleon.h ================================================ // // UILabel+Chameleon.h // Chameleon // // Created by Vicc Alexander on 9/20/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import @interface UILabel (Chameleon) - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR; @end ================================================ FILE: Pod/Classes/Objective-C/UILabel+Chameleon.m ================================================ // // UILabel+Chameleon.m // Chameleon // // Created by Vicc Alexander on 9/20/15. // Copyright © 2015 Vicc Alexander. All rights reserved. // #import "UILabel+Chameleon.h" @implementation UILabel (Chameleon) - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR { self.font = [UIFont fontWithName:name size:self.font.pointSize]; } @end ================================================ FILE: Pod/Classes/Objective-C/UINavigationController+Chameleon.h ================================================ // // UINavigationController+Chameleon.h // ChameleonDemo // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import #import "ChameleonEnums.h" @interface UINavigationController (Chameleon) /** * Sets the status bar style for the specified @c UINavigationController and all its child controllers. * * @param statusBarStyle The style of the device's status bar. * * @note Chameleon introduces a new @c statusBarStyle called @c UIStatusBarStyleContrast. * * @since 2.0 */ - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; /** * Hides the hairline view at the bottom of a navigation bar. The default value is @c NO. * * @since 2.0.3 */ @property (nonatomic, assign) BOOL hidesNavigationBarHairline; @end ================================================ FILE: Pod/Classes/Objective-C/UINavigationController+Chameleon.m ================================================ // // UINavigationController+Chameleon.m // ChameleonDemo // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "UINavigationController+Chameleon.h" #import #import "ChameleonConstants.h" #import "ChameleonEnums.h" #import "ChameleonMacros.h" #import "NSArray+Chameleon.h" #import "UIColor+Chameleon.h" #import "UIViewController+Chameleon.h" @interface UINavigationController () @property (readwrite) BOOL shouldContrast; @property (readwrite) BOOL shouldUseLightContent; @end @implementation UINavigationController (Chameleon) @dynamic hidesNavigationBarHairline; #pragma mark - Swizzling + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class class = [self class]; SEL originalSelector = @selector(viewDidLoad); SEL swizzledSelector = @selector(chameleon_viewDidLoad); Method originalMethod = class_getInstanceMethod(class, originalSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); if (didAddMethod) { class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); } else { method_exchangeImplementations(originalMethod, swizzledMethod); } }); } - (void)chameleon_viewDidLoad { [self chameleon_viewDidLoad]; UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; if (hairlineImageView) { if (self.hidesNavigationBarHairline) { hairlineImageView.hidden = YES; } else { hairlineImageView.hidden = NO; } } } - (UIImageView *)findHairlineImageViewUnder:(UIView *)view { if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) { return (UIImageView *)view; } for (UIView *subview in view.subviews) { UIImageView *imageView = [self findHairlineImageViewUnder:subview]; if (imageView) { return imageView; } } return nil; } #pragma mark - Runtime - (void)setShouldContrast:(BOOL)contrast { NSNumber *number = [NSNumber numberWithBool:contrast]; objc_setAssociatedObject(self, @selector(shouldContrast), number, OBJC_ASSOCIATION_RETAIN); } - (BOOL)shouldContrast { NSNumber *number = objc_getAssociatedObject(self, @selector(shouldContrast)); return [number boolValue]; } - (void)setShouldUseLightContent:(BOOL)shouldUseLightContent { NSNumber *number = [NSNumber numberWithBool:shouldUseLightContent]; objc_setAssociatedObject(self, @selector(shouldUseLightContent), number, OBJC_ASSOCIATION_RETAIN); } - (BOOL)shouldUseLightContent { NSNumber *number = objc_getAssociatedObject(self, @selector(shouldUseLightContent)); return [number boolValue]; } - (void)setHidesNavigationBarHairline:(BOOL)hidesNavigationBarHairline { NSNumber *number = [NSNumber numberWithBool:hidesNavigationBarHairline]; objc_setAssociatedObject(self, @selector(hidesNavigationBarHairline), number, OBJC_ASSOCIATION_RETAIN); //Find Hairline Image UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; //Check if it exists if (hairlineImageView) { //Check if we should hide it or not if (hidesNavigationBarHairline) { hairlineImageView.hidden = YES; } else { hairlineImageView.hidden = NO; } } } - (BOOL)hidesNavigationBarHairline { NSNumber *number = objc_getAssociatedObject(self, @selector(hidesNavigationBarHairline)); return [number boolValue]; } #pragma mark - Public Methods - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { if (statusBarStyle == UIStatusBarStyleContrast) { self.shouldContrast = YES; } else { if (statusBarStyle == UIStatusBarStyleLightContent) { self.shouldUseLightContent = YES; } else { self.shouldUseLightContent = NO; } } } #pragma mark - Private Methods - (UIStatusBarStyle)preferredStatusBarStyle { [super preferredStatusBarStyle]; if (self.shouldContrast) { return [self contrastingStatusBarStyleForColor:self.navigationBar.barTintColor]; } else { if (self.shouldUseLightContent) { return UIStatusBarStyleLightContent; } else { return UIStatusBarStyleDefault; } } } - (UIStatusBarStyle)contrastingStatusBarStyleForColor:(UIColor *)backgroundColor { //Calculate Luminance CGFloat luminance; CGFloat red, green, blue; //Check for clear or uncalculatable color and assume white if (![backgroundColor getRed:&red green:&green blue:&blue alpha:nil]) { return UIStatusBarStyleDefault; } //Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; luminance = red + green + blue; return (luminance > 0.6f) ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; } @end ================================================ FILE: Pod/Classes/Objective-C/UIView+ChameleonPrivate.h ================================================ // // UIView+ChameleonPrivate.h // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import @interface UIView (ChameleonPrivate) - (BOOL)isTopViewInWindow; - (UIView *)findTopMostViewForPoint:(CGPoint)point; @end ================================================ FILE: Pod/Classes/Objective-C/UIView+ChameleonPrivate.m ================================================ // // UIView+ChameleonPrivate.m // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "UIView+ChameleonPrivate.h" @implementation UIView (ChameleonPrivate) - (BOOL)isTopViewInWindow { if (!self.window) { return NO; } CGPoint centerPointInSelf = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); CGPoint centerPointOfSelfInWindow = [self convertPoint:centerPointInSelf toView:self.window]; UIView *view = [self.window findTopMostViewForPoint:centerPointOfSelfInWindow]; BOOL isTopMost = view == self || [view isDescendantOfView:self]; return isTopMost; } - (UIView *)findTopMostViewForPoint:(CGPoint)point { for (int i = (int)self.subviews.count - 1; i >= 0; i--) { UIView *subview = self.subviews[i]; if (!subview.hidden && CGRectContainsPoint(subview.frame, point) && subview.alpha > 0.01) { CGPoint pointConverted = [self convertPoint:point toView:subview]; return [subview findTopMostViewForPoint:pointConverted]; } } return self; } @end ================================================ FILE: Pod/Classes/Objective-C/UIViewController+Chameleon.h ================================================ // // UIViewController+Chameleon.h // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import #import "ChameleonEnums.h" @interface UIViewController (Chameleon) /** * Sets the color theme for the specified view controller using a primary color and the specified content style. * * @param primaryColor The primary color. * @param contentStyle The contentStyle. * * @since 2.0 */ - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle; /** * Sets the color theme for the specified view controller using a primary color, secondary color, and the specified content style. * * @param primaryColor The primary color. * @param secondaryColor The secondary color. * @param contentStyle The contentStyle. * * @since 2.0 */ - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle; /** * Sets the color theme for the specified view controller using a primary color, secondary color, font name, and the specified content style. * * @param primaryColor The primary color. * @param secondaryColor The secondary color. * @param fontName The main font to use for all text-based elements. * @param contentStyle The contentStyle. * * @since 2.0 */ - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle; /** * Sets the status bar style for the specified @c UIViewController and all its child controllers. * * @param statusBarStyle The style of the device's status bar. * * @note Chameleon introduces a new @c statusBarStyle called @c UIStatusBarStyleContrast. * * @since 2.0 */ - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; @end ================================================ FILE: Pod/Classes/Objective-C/UIViewController+Chameleon.m ================================================ // // UIViewController+Chameleon.m // Chameleon // // Created by Vicc Alexander on 6/4/15. // Copyright (c) 2015 Vicc Alexander. All rights reserved. // #import "UIViewController+Chameleon.h" #import #import "ChameleonConstants.h" #import "ChameleonEnums.h" #import "ChameleonMacros.h" #import "NSArray+Chameleon.h" #import "UIColor+Chameleon.h" #import "UIViewController+Chameleon.h" #import "UIView+ChameleonPrivate.h" #import "UILabel+Chameleon.h" #import "UIButton+Chameleon.h" #import "UIAppearance+Swift.h" @interface UIViewController () @property (readwrite) BOOL shouldContrast; @property (readwrite) BOOL shouldUseLightContent; @end @implementation UIViewController (Chameleon) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma mark - Runtime - (void)setShouldContrast:(BOOL)contrast { NSNumber *number = [NSNumber numberWithBool:contrast]; objc_setAssociatedObject(self, @selector(shouldContrast), number, OBJC_ASSOCIATION_RETAIN); } - (BOOL)shouldContrast { NSNumber *number = objc_getAssociatedObject(self, @selector(shouldContrast)); return [number boolValue]; } - (void)setShouldUseLightContent:(BOOL)shouldUseLightContent { NSNumber *number = [NSNumber numberWithBool:shouldUseLightContent]; objc_setAssociatedObject(self, @selector(shouldUseLightContent), number, OBJC_ASSOCIATION_RETAIN); } - (BOOL)shouldUseLightContent { NSNumber *number = objc_getAssociatedObject(self, @selector(shouldUseLightContent)); return [number boolValue]; } #pragma mark - Swizzling + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class class = [self class]; SEL originalSelector = @selector(preferredStatusBarStyle); SEL swizzledSelector = @selector(chameleon_preferredStatusBarStyle); Method originalMethod = class_getInstanceMethod(class, originalSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); if (didAddMethod) { class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); } else { method_exchangeImplementations(originalMethod, swizzledMethod); } }); } #pragma mark - Methods - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { if (statusBarStyle == UIStatusBarStyleContrast) { [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil afterDelay:0.01]; self.shouldContrast = YES; } else { if (statusBarStyle == UIStatusBarStyleLightContent) { [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil afterDelay:0.01]; self.shouldUseLightContent = YES; } else { [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil afterDelay:0.01]; self.shouldUseLightContent = NO; } } [self preferredStatusBarStyle]; } - (UIStatusBarStyle)chameleon_preferredStatusBarStyle { [self chameleon_preferredStatusBarStyle]; if (self.shouldContrast) { CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; UIView *topView = [self.view findTopMostViewForPoint:CGPointMake(CGRectGetMidX(statusBarFrame), 2)]; return [self contrastingStatusBarStyleForColor:topView.backgroundColor]; } else { if (self.shouldUseLightContent) { return UIStatusBarStyleLightContent; } else { return [self chameleon_preferredStatusBarStyle]; } } } - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } } else if (contentStyle == UIContentStyleLight) { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } else { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } [[UILabel appearance] setSubstituteFontName:fontName]; [[UIButton appearance] setSubstituteFontName:fontName]; [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; [[self class] customizeNavigationBarWithBarColor:primaryColor textColor:ContrastColor(primaryColor, YES) fontName:fontName fontSize:20 buttonColor:ContrastColor(primaryColor, YES)]; [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withFontName:fontName withFontSize:14 withContentStyle:contentStyle]; [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } #pragma mark - UIBarButtonItem + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor contentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIBarButtonItem appearance] setTintColor:primaryColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; } + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor fontName:(NSString *)fontName fontSize:(float)fontSize contentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIBarButtonItem appearance] setTintColor:primaryColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; if ([UIFont fontWithName:fontName size:fontSize]) { [[UIBarButtonItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:contentColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize]} forState:UIControlStateNormal]; } } #pragma mark - UIButton + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIButton appearance] setTintColor:contentColor]; [[UIButton appearance] setBackgroundColor:primaryColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; } + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor secondaryColor:(UIColor *)secondaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; UIColor *secondaryContentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); secondaryContentColor = ContrastColor(secondaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; secondaryContentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; secondaryContentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); secondaryContentColor = ContrastColor(secondaryColor, NO); break; } } [[UIButton appearance] setTintColor:secondaryContentColor]; [[UIButton appearance] setBackgroundColor:secondaryColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; } #pragma mark - UIImagePickerController + (void)customizeImagePickerControllerWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } //Workaround for Swift http://stackoverflow.com/a/28765193 [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setTintColor:ClearColor]; [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; [[UIButton appearanceWhenContainedWithin:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setTintColor:contentColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; } #pragma mark - UILabel + (void)customizeLabelWithPrimaryColor:(UIColor *)primaryColor fontName:(NSString *)fontName fontSize:(CGFloat)fontSize withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UILabel appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTextColor:contentColor]; [[UILabel appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTextColor:contentColor]; UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UILabel appearanceWhenContainedIn:[self class], nil] setFont:[UIFont fontWithName:fontName size:fontSize]]; [[UILabel appearanceWhenContainedIn:[self class], [UITextField class], nil] setFont:[UIFont fontWithName:fontName size:14]]; [[UILabel appearanceWhenContainedIn:[self class], [UIButton class], nil] setFont:[UIFont fontWithName:fontName size:18]]; } } #pragma mark - UINavigationBar + (void)customizeNavigationBarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:primaryColor]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTintColor:contentColor]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName:contentColor}]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setShadowImage:[UIImage new]]; // [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor textColor:(UIColor *)textColor buttonColor:(UIColor *)buttonColor { [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barColor]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTintColor:buttonColor]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName:textColor}]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setShadowImage:[UIImage new]]; // [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor textColor:(UIColor *)textColor fontName:(NSString *)fontName fontSize:(CGFloat)fontSize buttonColor:(UIColor *)buttonColor { [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barColor]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTintColor:buttonColor]; [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setShadowImage:[UIImage new]]; // [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; if ([UIFont fontWithName:fontName size:fontSize]) { [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{ NSForegroundColorAttributeName:textColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize] }]; } } #pragma mark - UIPageControl + (void)customizePageControlWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIPageControl appearanceWhenContainedIn:[self class], nil] setCurrentPageIndicatorTintColor:primaryColor]; [[UIPageControl appearanceWhenContainedIn:[self class], nil] setPageIndicatorTintColor:[primaryColor colorWithAlphaComponent:0.4]]; [[UIPageControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setCurrentPageIndicatorTintColor:contentColor]; [[UIPageControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; [[UIPageControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setCurrentPageIndicatorTintColor:contentColor]; [[UIPageControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; } #pragma mark - UIProgressView + (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIProgressView appearanceWhenContainedIn:[self class], nil] setProgressTintColor:primaryColor]; [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setProgressTintColor:contentColor]; [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setProgressTintColor:contentColor]; [[UIProgressView appearanceWhenContainedIn:[self class], nil] setTrackTintColor:[UIColor lightGrayColor]]; [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } + (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor andSecondaryColor:(UIColor *)secondaryColor { [[UIProgressView appearanceWhenContainedIn:[self class], nil] setProgressTintColor:secondaryColor]; [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setProgressTintColor:secondaryColor]; [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setProgressTintColor:secondaryColor]; [[UIProgressView appearanceWhenContainedIn:[self class], nil] setTrackTintColor:[UIColor lightGrayColor]]; [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } #pragma mark - UISearchBar + (void)customizeSearchBarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISearchBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:primaryColor]; [[UISearchBar appearanceWhenContainedIn:[self class], nil] setBackgroundColor:primaryColor]; [[UISearchBar appearanceWhenContainedIn:[self class], nil] setTintColor:contentColor]; [[UISearchBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; } #pragma mark - UISegmentedControl + (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISegmentedControl appearanceWhenContainedIn:[self class], nil] setTintColor:primaryColor]; [[UISegmentedControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTintColor:contentColor]; [[UISegmentedControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTintColor:contentColor]; } + (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor withFontName:(NSString *)fontName withFontSize:(CGFloat)fontSize withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISegmentedControl appearanceWhenContainedIn:[self class], nil] setTintColor:primaryColor]; [[UISegmentedControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTintColor:contentColor]; [[UISegmentedControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTintColor:contentColor]; UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UISegmentedControl appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateNormal]; } } #pragma mark - UISlider + (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UISlider appearanceWhenContainedIn:[self class], nil] setMinimumTrackTintColor:primaryColor]; [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMinimumTrackTintColor:contentColor]; [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMinimumTrackTintColor:contentColor]; [[UISlider appearanceWhenContainedIn:[self class], nil] setMaximumTrackTintColor:[UIColor lightGrayColor]]; [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } + (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor andSecondaryColor:(UIColor *)secondaryColor { [[UISlider appearanceWhenContainedIn:[self class], nil] setMinimumTrackTintColor:secondaryColor]; [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMinimumTrackTintColor:secondaryColor]; [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMinimumTrackTintColor:secondaryColor]; [[UISlider appearanceWhenContainedIn:[self class], nil] setMaximumTrackTintColor:[UIColor lightGrayColor]]; [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } #pragma mark - UIStepper + (void)customizeStepperWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIStepper appearanceWhenContainedIn:[self class], nil] setTintColor:primaryColor]; [[UIStepper appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTintColor:contentColor]; [[UIStepper appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTintColor:contentColor]; } #pragma mark - UISwitch + (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor { [[UISwitch appearanceWhenContainedIn:[self class], nil] setOnTintColor:primaryColor]; [[UISwitch appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; [[UISwitch appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; } + (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor andSecondaryColor:(UIColor *)secondaryColor { [[UISwitch appearanceWhenContainedIn:[self class], nil] setOnTintColor:secondaryColor]; [[UISwitch appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setOnTintColor:secondaryColor]; [[UISwitch appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setOnTintColor:secondaryColor]; } #pragma mark - UITabBar + (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor andTintColor:(UIColor *)tintColor { [[UITabBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barTintColor]; [[UITabBar appearanceWhenContainedIn:[self class], nil] setTintColor:tintColor]; } + (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor tintColor:(UIColor *)tintColor fontName:(NSString *)fontName fontSize:(CGFloat)fontSize { [[UITabBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barTintColor]; [[UITabBar appearanceWhenContainedIn:[self class], nil] setTintColor:tintColor]; UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UITabBarItem appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateNormal]; } } #pragma mark - UIToolbar + (void)customizeToolbarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { UIColor *contentColor; switch (contentStyle) { case UIContentStyleContrast: { contentColor = ContrastColor(primaryColor, NO); break; } case UIContentStyleLight: { contentColor = [UIColor whiteColor]; break; } case UIContentStyleDark: { contentColor = FlatBlackDark; break; } default: { contentColor = ContrastColor(primaryColor, NO); break; } } [[UIToolbar appearanceWhenContainedIn:[self class], nil] setTintColor:contentColor]; [[UIToolbar appearanceWhenContainedIn:[self class], nil] setBarTintColor:primaryColor]; [[UIToolbar appearanceWhenContainedIn:[self class], nil] setClipsToBounds:YES]; } #pragma mark - Private Methods - (UIStatusBarStyle)contrastingStatusBarStyleForColor:(UIColor *)backgroundColor { //Calculate Luminance CGFloat luminance; CGFloat red, green, blue; //Check for clear or uncalculatable color and assume white if (![backgroundColor getRed:&red green:&green blue:&blue alpha:nil]) { return UIStatusBarStyleDefault; } //Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; luminance = red + green + blue; return (luminance > 0.6f) ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; } #pragma GCC diagnostic pop @end ================================================ FILE: Pod/Classes/Swift/ChameleonShorthand.swift ================================================ // ChameleonShorthand.swift /* The MIT License (MIT) Copyright (c) 2014-2015 Vicc Alexander. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import UIKit // MARK: - UIColor Methods Shorthand /** Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. - parameter color: The color whose complementary color is being requested. - returns: A flat UIColor object in the HSB colorspace. */ public func ComplementaryFlatColorOf(_ color: UIColor) -> UIColor { return UIColor(complementaryFlatColorOf: color) } /** Returns a randomly generated flat color object with an alpha value of 1.0 in either a light or dark shade. - parameter shade: Specifies whether the randomly generated flat color should be a light or dark shade. - returns: A flat UIColor object in the HSB colorspace. */ public func RandomFlatColorWithShade(_ shade: UIShadeStyle) -> UIColor { return UIColor(randomFlatColorOf: shade) } /** Creates and returns either a black or white color object depending on which contrasts more with a specified color. - parameter backgroundColor: The specified color of the contrast color that is being requested. - parameter returnFlat: Pass **true** to return flat color objects. - returns: A UIColor object in the HSB colorspace. */ public func ContrastColorOf(_ backgroundColor: UIColor, returnFlat: Bool) -> UIColor { return UIColor(contrastingBlackOrWhiteColorOn: backgroundColor, isFlat: returnFlat) } /** Creates and returns a gradient as a color object with an alpha value of 1.0 - parameter gradientStyle: Specifies the style and direction of the gradual blend between colors. - parameter frame: The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. - parameter colors: An array of color objects used to create a gradient. - returns: A UIColor object using colorWithPattern. */ public func GradientColor(_ gradientStyle: UIGradientStyle, frame: CGRect, colors: [UIColor]) -> UIColor { return UIColor(gradientStyle: gradientStyle, withFrame: frame, andColors: colors) } public func HexColor(_ hexString: String, _ alpha: CGFloat = 1.0) -> UIColor? { return UIColor(hexString: hexString, withAlpha: alpha) } /** Returns the average color generated by averaging the colors of a specified image. - parameter image: A specified UIImage. - returns: A flat UIColor object in the HSB colorspace. */ public func AverageColorFromImage(_ image: UIImage) -> UIColor { return UIColor(averageColorFrom: image) } // MARK: - Array Methods Shorthand // TODO Array Extension needed ;) /** Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. - parameter colorSchemeType: The color scheme with which to select colors using a specified color. - parameter color: The specified color which the color scheme is built around. - parameter isFlatScheme: Pass *true* to return flat color objects. - returns: An array of 5 color objects in the HSB colorspace. */ public func ColorSchemeOf(_ colorSchemeType:ColorScheme, color:UIColor, isFlatScheme:Bool) -> [UIColor] { return NSArray(ofColorsWith: colorSchemeType, using: color, withFlatScheme: isFlatScheme) as! [UIColor] } /** Generates and creates an array of 5 color objects in the HSB colorspace that appear most often in a specified image. - parameter image: The specified image which the color scheme is built around. - parameter withFlatScheme: Pass **true** to return flat color objects. - returns: An array of 5 color objects in the HSB colorspace. */ public func ColorsFromImage(_ image: UIImage, withFlatScheme: Bool) -> [UIColor] { // TODO: Remove forced casting return NSArray(ofColorsFrom: image, withFlatScheme: withFlatScheme) as! [UIColor] } // MARK: - Special Colors Shorthand /** Returns a randomly generated flat color object whose alpha value is 1.0. - returns: A flat UIColor object in the HSB colorspace. */ public func RandomFlatColor() -> UIColor { return UIColor.randomFlat } public func ClearColor() -> UIColor { return UIColor.clear } // MARK: - Light Shades Shorthand public func FlatBlack() -> UIColor { return UIColor.flatBlack } public func FlatBlue() -> UIColor { return UIColor.flatBlue } public func FlatBrown() -> UIColor { return UIColor.flatBrown } public func FlatCoffee() -> UIColor { return UIColor.flatCoffee } public func FlatForestGreen() -> UIColor { return UIColor.flatForestGreen } public func FlatGray() -> UIColor { return UIColor.flatGray } public func FlatGreen() -> UIColor { return UIColor.flatGreen } public func FlatLime() -> UIColor { return UIColor.flatLime } public func FlatMagenta() -> UIColor { return UIColor.flatMagenta } public func FlatMaroon() -> UIColor { return UIColor.flatMaroon } public func FlatMint() -> UIColor { return UIColor.flatMint } public func FlatNavyBlue() -> UIColor { return UIColor.flatNavyBlue } public func FlatOrange() -> UIColor { return UIColor.flatOrange } public func FlatPink() -> UIColor { return UIColor.flatPink } public func FlatPlum() -> UIColor { return UIColor.flatPlum } public func FlatPowderBlue() -> UIColor { return UIColor.flatPowderBlue } public func FlatPurple() -> UIColor { return UIColor.flatPurple } public func FlatRed() -> UIColor { return UIColor.flatRed } public func FlatSand() -> UIColor { return UIColor.flatSand } public func FlatSkyBlue() -> UIColor { return UIColor.flatSkyBlue } public func FlatTeal() -> UIColor { return UIColor.flatTeal } public func FlatWatermelon() -> UIColor { return UIColor.flatWatermelon } public func FlatWhite() -> UIColor { return UIColor.flatWhite } public func FlatYellow() -> UIColor { return UIColor.flatYellow } // MARK: - Chameleon - Dark Shades Shorthand public func FlatBlackDark() -> UIColor { return UIColor.flatBlackDark } public func FlatBlueDark() -> UIColor { return UIColor.flatBlueDark } public func FlatBrownDark() -> UIColor { return UIColor.flatBrownDark } public func FlatCoffeeDark() -> UIColor { return UIColor.flatCoffeeDark } public func FlatForestGreenDark() -> UIColor { return UIColor.flatForestGreenDark } public func FlatGrayDark() -> UIColor { return UIColor.flatGrayDark } public func FlatGreenDark() -> UIColor { return UIColor.flatGreenDark } public func FlatLimeDark() -> UIColor { return UIColor.flatLimeDark } public func FlatMagentaDark() -> UIColor { return UIColor.flatMagentaDark } public func FlatMaroonDark() -> UIColor { return UIColor.flatMaroonDark } public func FlatMintDark() -> UIColor { return UIColor.flatMintDark } public func FlatNavyBlueDark() -> UIColor { return UIColor.flatNavyBlueDark } public func FlatOrangeDark() -> UIColor { return UIColor.flatOrangeDark } public func FlatPinkDark() -> UIColor { return UIColor.flatPinkDark } public func FlatPlumDark() -> UIColor { return UIColor.flatPlumDark } public func FlatPowderBlueDark() -> UIColor { return UIColor.flatPowderBlueDark } public func FlatPurpleDark() -> UIColor { return UIColor.flatPurpleDark } public func FlatRedDark() -> UIColor { return UIColor.flatRedDark } public func FlatSandDark() -> UIColor { return UIColor.flatSandDark } public func FlatSkyBlueDark() -> UIColor { return UIColor.flatSkyBlueDark } public func FlatTealDark() -> UIColor { return UIColor.flatTealDark } public func FlatWatermelonDark() -> UIColor { return UIColor.flatWatermelonDark } public func FlatWhiteDark() -> UIColor { return UIColor.flatWhiteDark } public func FlatYellowDark() -> UIColor { return UIColor.flatYellowDark } ================================================ FILE: README.md ================================================

Chameleon by Vicc Alexander

Downloads Apps Platform: iOS 8+ Language: Swift 3 Carthage compatible CocoaPods compatible License: MIT

## Swift 3 To use the Swift 3 version, add this to your Podfile (until 2.2 or higher is released): ```ruby pod 'ChameleonFramework/Swift', :git => 'https://github.com/ViccAlexander/Chameleon.git' ``` ## Introduction **Chameleon** is a lightweight, yet powerful, color framework for iOS (Objective-C & Swift). It is built on the idea that software applications should function effortlessly while simultaneously maintaining their beautiful interfaces. With Chameleon, you can easily stop tinkering with RGB values, wasting hours figuring out the right color combinations to use in your app, and worrying about whether your text will be readable on the various background colors of your app. ### Features

Features

### App Showcase ###### In an upcoming update we'll begin showcasing some of the best apps and companies making use of Chameleon. If you'd like to see your app featured in this section, make sure to add it [here](https://airtable.com/shrr1WK6dLQBZfXV0). ## Table of Contents [● Product Features](https://github.com/ViccAlexander/Chameleon#-product-features) [● Requirements](https://github.com/ViccAlexander/Chameleon#%EF%B8%8F-requirements) [● License](https://github.com/ViccAlexander/Chameleon#-license) [● Contributions](https://github.com/ViccAlexander/Chameleon#-contributions) [● Documentation](https://github.com/ViccAlexander/Chameleon#-documentation) [● Storyboard Add-On](https://github.com/ViccAlexander/Chameleon#storyboard-add-on) [● Author](https://github.com/ViccAlexander/Chameleon#-author) [● To Do List](https://github.com/ViccAlexander/Chameleon#-to-do-list) [● Change Log](https://github.com/ViccAlexander/Chameleon#-change-log) ## 🌟 Product Features ### 100% Flat & Gorgeous Chameleon features over 24 hand-picked colors that come in both light and dark shades.

Swatches

### Flat Color Schemes Chameleon equips you with 3 different classes of flat color schemes that can be generated from a flat or non-flat color. *In the examples below, the white stars indicate the color used to generate the schemes.* ###### Analogous Flat Color Scheme

Analogous Scheme

###### Complementary Flat Color Scheme

Complementary Scheme

###### Triadic Flat Color Scheme

Triadic Scheme

### Contrasting Text With a plethora of color choices available for text, it's difficult to choose one that all users will appreciate and be able to read. Whether you're in doubt of your text and tint color choices, or afraid to let users customize their profile colors because it may disturb the legibility or usability of the app, you no longer have to worry. With Chameleon, you can ensure that all text stands out independent of the background color. Oh... Chameleon works with the status bar as well. : )

Status Bar

### Themes ![Beta](http://i.imgur.com/JyYiUJq.png) Chameleon now allows you easily theme your app with as little as **one line of code**. You can set a theme for all your views, and for specific views as well.

Themes

### Colors From Images Chameleon allows you to seamlessly extract non-flat or flat color schemes from images without hassle. You can also generate the average color from an image with ease. You can now mold the UI colors of a profile, or product based on an image!

Colors from images

### Gradient Colors With iOS 7 & 8, Apple mainstreamed flat colors. Now, with the release of iOS 9, Chameleon strives to elevate the game once more. Say hello to gradient colors. Using one line of code, you can easily set any object's color properties to a gradient (background colors, text colors, tint colors, etc). Other features, like Chameleon's contrasting feature, can also be applied to create a seamless product. Experimentation is encouraged, and gutsiness is applauded!

Gradients

![](http://i.imgur.com/2jN72eh.png) ### Xcode Quick Help Documentation Chameleon's documentation, while written as clearly and concisely as possible may still render some slightly confused. But don't fret! Staying true to our vision of simplifying the entire color process, we added Xcode Quick Help's Documentation Support! Simply highlight a Chameleon method or tap it with three fingers to find out more about what it is and what it does!

Xcode Quick Help Documentation

### Palettes If you're like us and love to use storyboards, Chameleon's got you covered. We've provided you with a quick and easy way to access Chameleon colors right from Storyboard, and any other app that uses the color picker (i.e. TextEdit). In addition you can even import the palette directly into Photoshop and Sketch.

Chameleon Palette

Chameleon Palette

## ⚠️ Requirements * Objective-C or Swift * Requires a minimum of iOS 7.0 for Objective-C (No active development for anything earlier, but may work with 6.0) and a minimum of iOS 8.0 for Swift. * Requires Xcode 6.3 for use in any iOS Project ## 🔑 License Chameleon is released and distributed under the terms and conditions of the [MIT license](https://github.com/ViccAlexander/Chameleon/blob/master/LICENSE.md). ## 👥 Contributions If you run into problems, please open up an issue. We also actively welcome pull requests. By contributing to Chameleon you agree that your contributions will be licensed under its MIT license. If you use Chameleon in your app we would love to hear about it! Drop Vicc a line on [twitter](http://twitter.com/viccsmind). ## 📗 Documentation All methods, properties, and types available in Chameleon are documented below. ##### Documentation Table of Contents [● Installation](https://github.com/ViccAlexander/Chameleon#installation) [● Palettes](https://github.com/ViccAlexander/Chameleon#palettes) [● Usage](https://github.com/ViccAlexander/Chameleon#usage) [● UIColor Methods](https://github.com/ViccAlexander/Chameleon#uicolor-methods) [● Colors From Images](https://github.com/ViccAlexander/Chameleon#colors-from-images) [● UIStatusBarStyle Methods](https://github.com/ViccAlexander/Chameleon#uistatusbarstyle-methods) [● Color Scheme Methods](https://github.com/ViccAlexander/Chameleon#color-schemes-methods) [● Theme Methods](https://github.com/ViccAlexander/Chameleon#theme-methods) ### Installation ###### Note: Swift 3 version maintained in a separate branch until it's release. #### CocoaPods Installation Chameleon is now available on [CocoaPods](http://cocoapods.org). Simply add the following to your project Podfile, and you'll be good to go. ###### Objective-C ```ruby use_frameworks! pod 'ChameleonFramework' ``` ###### Swift ```ruby use_frameworks! pod 'ChameleonFramework/Swift' ``` ======= #### Carthage Installation Add this to your Cartfile: ```ruby github "ViccAlexander/Chameleon" ``` ======= #### Manual Installation If you rather install this framework manually, just drag and drop the Chameleon folder into your project, and make sure you check the following boxes. Note: Don't forget to manually import the *QuartzCore* & *CoreGraphics* framework if you plan on using gradient colors!

Manual Installation

If you're working with Swift and are manually installing Chameleon, there's an additional step. Make sure to download and drag the following file, [ChameleonShorthand.swift](https://github.com/ViccAlexander/Chameleon/blob/master/Pod/Classes/Swift/ChameleonShorthand.swift), into your project, and you'll be good to go. #### Palettes ##### Storyboard Add-On Using Chameleon's awesome palette in Storyboard is easy! Simply download and install [Chameleon Palette](https://github.com/ViccAlexander/Chameleon/blob/master/Extras/Chameleon.dmg?raw=true). Once installed, make sure to restart Xcode. You'll find all of Chameleon's colors in the Palette Color Picker whenever they're needed! :)

Chameleon Palette

Chameleon Palette

##### Photoshop Add-On Using Chameleon's awesome palette in Sketch is easy! Simply download and install [Photoshop Palette](https://github.com/ViccAlexander/Chameleon/blob/master/Extras/Chameleon_Photoshop.aco?raw=true). ##### Sketch Add-On Using Chameleon's awesome palette in Sketch is easy! Simply download and install [Sketch Palette](https://github.com/ViccAlexander/Chameleon/blob/master/Extras/Chameleon.sketchpalette?raw=true). ### Usage To use the myriad of features in Chameleon, include the following import: ###### If you installed Chameleon using CocoaPods: ###### Objective-C ``` objective-c #import ``` ###### Swift: ``` swift import ChameleonFramework ``` ###### If you installed Chameleon using Carthage: ``` swift import Chameleon ``` ###### If you installed Chameleon manually: ``` objective-c #import "Chameleon.h" ``` ### UIColor Methods [● Flat Colors](https://github.com/ViccAlexander/Chameleon#flat-colors) [● Random Colors](https://github.com/ViccAlexander/Chameleon#random-colors) [● Complementary Colors](https://github.com/ViccAlexander/Chameleon#complementary-colors) [● Contrasting Colors](https://github.com/ViccAlexander/Chameleon#contrasting-colors) [● Flattening Non-Flat Colors](https://github.com/ViccAlexander/Chameleon#flattening-non-flat-colors) [● Gradient Colors](https://github.com/ViccAlexander/Chameleon#gradient-colors-1) [● Hex Colors](https://github.com/ViccAlexander/Chameleon#hex-colors-) [● Lighter & Darker Colors](https://github.com/ViccAlexander/Chameleon#lighter-and-darker-colors-) #### Flat Colors Using a flat color is as easy as adding any other color in your app (if not easier). For example, to set a view's background property to a flat color with a dark shade, you simply have to do the following: ##### Normal Convention: ###### Objective-C ``` objective-c self.view.backgroundColor = [UIColor flatGreenColorDark]; ``` ###### Swift ``` swift view.backgroundColor = UIColor.flatGreenDark ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c self.view.backgroundColor = FlatGreenDark; ``` ###### Swift ``` swift view.backgroundColor = FlatGreenDark() ``` Setting the color for a light shade is the same, except without adding the *Dark* suffix. (By default, all colors without a *Dark* suffix are light shades). For example: ##### Normal Convention: ###### Objective-C ``` objective-c self.view.backgroundColor = [UIColor flatGreenColor]; ``` ###### Swift ``` swift view.backgroundColor = UIColor.flatGreen ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c self.view.backgroundColor = FlatGreen; ``` ###### Swift ``` swift view.backgroundColor = FlatGreen() ``` #### Random Colors There are four ways to generate a random flat color. If you have no preference as to whether you want a light shade or a dark shade, you can do the following: ##### Normal Convention: ###### Objective-C ``` objective-c self.view.backgroundColor = [UIColor randomFlatColor]; ``` ###### Swift ``` swift view.backgroundColor = UIColor.randomFlat ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c self.view.backgroundColor = RandomFlatColor; ``` ###### Swift ``` swift view.backgroundColor = RandomFlatColor() ``` Otherwise, you can perform the following method call to specify whether it should return either a light or dark shade: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithRandomFlatColorOfShadeStyle:UIShadeStyleLight]; ``` ###### Swift ``` swift UIColor(randomFlatColorOfShadeStyle:.Light) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c RandomFlatColorWithShade(UIShadeStyleLight); ``` ###### Swift ``` swift RandomFlatColorWithShade(.Light) ``` **UIShadeStyles:** - `UIShadeStyleLight` (`UIShadeStyle.Light` in Swift) - `UIShadeStyleDark` (`UIShadeStyle.Dark` in Swift) ##### Choosing A Random Color From a List of Colors ![New](http://i.imgur.com/BX3b9ES.png) If you need to be a bit more selective and only display a random color from a set list of colors, you can use the following method: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithRandomColorInArray:@[FlatWhite, FlatRed, FlatBlue]]; ``` ###### Swift ``` swift TBA ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c RandomFlatColorInArray(@[FlatWhite, FlatRed, FlatBlue]) ``` ###### Swift ``` swift TBA ``` ##### Choosing A Random Flat Color But Excluding A Few ![New](http://i.imgur.com/BX3b9ES.png) Last but certainly not least, you can also choose form the list of random colors and exclude the ones you don't want. For example say you want to randomly select a flat color for a user's profile, but don't want to use any blacks, grays, or whites. You can simply do: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithRandomFlatColorExcludingColorsInArray:@[FlatBlack, FlatBlackDark, FlatGray, FlatGrayDark, FlatWhite, FlatWhiteDark]]; ``` ###### Swift ``` swift TBA ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c RandomFlatColorExcluding(@[FlatBlack, FlatBlackDark, FlatGray, FlatGrayDark, FlatWhite, FlatWhiteDark]) ``` ###### Swift ``` swift TBA ``` #### Complementary Colors To generate a complementary color, perform the following method call, remembering to specify the color whose complement you want: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithComplementaryFlatColorOf:(UIColor *)someUIColor]; ``` ###### Swift ``` swift UIColor(complementaryFlatColorOf:someUIColor) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c ComplementaryFlatColorOf(color); ``` ###### Swift ``` swift ComplementaryFlatColorOf(color) ``` #### Contrasting Colors The contrasting color feature returns either a dark color a light color depending on what the Chameleon algorithm believes is a better choice. You can specify whether the dark or light colors are flat: *`([UIColor flatWhiteColor]` & `[UIColor flatBlackColorDark]`)* or non-flat *(`[UIColor whiteColor]` & `[UIColor blackColor]`).* If you're trying to set a `UILabel's textColor` property, make sure you provide the `UILabel's backgroundColor`. If your label has a clear `backgroundColor`, just provide the `backgroundColor` property of the object directly behind the `UILabel`. Here's an example: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat]; ``` ###### Swift ``` swift UIColor(contrastingBlackOrWhiteColorOn:UIColor!, isFlat:Bool) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c ContrastColor(backgroundColor, isFlat); ``` ###### Swift ``` swift ContrastColor(backgroundColor, isFlat) ``` #### Flattening Non-Flat Colors As mentioned previously, this feature is unique to Chameleon. While this feature is in its early stages of operation and can be improved, it is accurate in finding the nearest flat version of any color in the spectrum, and very simple to use: ##### Normal Convention: ###### Objective-C ``` objective-c [(UIColor *)color flatten]; ``` ###### Swift ``` swift UIColor.pink.flatten() ``` #### Gradient Colors Using a gradient to color an object usually requires a couple of lines of code plus many more lines to superimpose smart contrasting text. Thankfully, Chameleon takes care of that for you. We've introduced a new way to have multicolored objects, and that's with gradients! ##### Gradient Styles Chameleon provides three simple gradient styles. Gradients can be created from any number of colors you desire as long as at least two colors are provided. Don't forget that the contrasting text feature is also compatible with gradient colors! **UIGradientStyles:** * `UIGradientStyleLeftToRight` (UIGradientStyle.LeftToRight in Swift) * `UIGradientStyleTopToBottom` (UIGradientStyle.TopToBottom in Swift) * `UIGradientStyleRadial` (UIGradientStyle.Radial in Swift) ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray *)colors]; ``` ###### Swift ``` swift UIColor(gradientStyle:UIGradientStyle, withFrame:CGRect, andColors:[UIColor]) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c GradientColor(gradientStyle, frame, colors); ``` ###### Swift ``` swift GradientColor(gradientStyle, frame, colors) ``` **Objective-C Note**: If you use the Chameleon Shorthand, and use the `NSArray` literal ```@[]``` to set the array of colors, make sure you add parenthesis around it, or else you'll get an error. Note: `UIGradientStyleRadial` only uses a maximum of 2 colors at the moment. So if more colors are provided, they will not show. #### Hex Colors One of the most requested features, *hex colors*, is now available. You can simply provide a hex string with or without a *#* sign: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithHexString:(NSString *)string]; ``` ###### Swift ``` swift UIColor(hexString:string) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c HexColor(hexString) ``` ###### Swift ``` swift HexColor(hexString) ``` #### Hex Values ![New](http://i.imgur.com/BX3b9ES.png) Retrieving the `hexValue` of a UIColor is just as easy. ###### Objective-C ``` objective-c [FlatGreen hexValue]; //Returns @"2ecc71" ``` ###### Swift ``` swift FlatGreen.hexValue //Returns @"2ecc71" ``` #### Lighter and Darker Colors Sometimes all you need is a color a shade lighter or a shade darker. Well for those rare, but crucial moments, Chameleon's got you covered. You can now lighten any color the following way: ##### Normal Convention: ###### Objective-C ``` objective-c [color lightenByPercentage:(CGFloat)percentage]; ``` ###### Swift ``` swift color.lightenByPercentage(percentage: CGFloat) ``` You can also generate a darker version of a color: ##### Normal Convention: ###### Objective-C ``` objective-c [color darkenByPercentage:(CGFloat)percentage]; ``` ###### Swift ``` swift color.darkenByPercentage(percentage: CGFloat) ``` ### Colors From Images Chameleon now supports the extraction of colors from images. You can either generate both flat and non-flat color schemes from an image, or easily extract the average color. To generate a color scheme simply do the following: ##### Normal Convention: ###### Objective-C ``` objective-c [NSArray arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)flatScheme]; ``` ###### Swift (**Array extension missing**) ``` swift NSArray(ofColorsFromImage: UIImage, withFlatScheme: Bool) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c ColorsFromImage(image, isFlatScheme) ``` ###### Swift ``` swift ColorsFromImage(image, isFlatScheme) ``` To extract the average color from an image, you can also do: ##### Normal Convention: ###### Objective-C ``` objective-c [UIColor colorWithAverageColorFromImage:(UIImage *)image]; ``` ###### Swift ``` swift UIColor(averageColorFromImage: UIImage) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c AverageColorFromImage(image) ``` ###### Swift ``` swift AverageColorFromImage(image) ``` ### UIStatusBarStyle Methods #### Contrasting UIStatusBarStyle Many apps on the market, even the most popular ones, overlook this aspect of a beautiful app: the status bar style. Chameleon has done something no other framework has... it has created a new status bar style: `UIStatusBarStyleContrast`. Whether you have a `ViewController` embedded in a `NavigationController`, or not, you can do the following: ##### Normal Convention: ###### Objective-C ``` objective-c [self setStatusBarStyle:UIStatusBarStyleContrast]; ``` ###### Swift ``` swift self.setStatusBarStyle(UIStatusBarStyleContrast) ``` ###### **Note**: Make sure that the key *View controller-based status bar appearance* in **Info.plist** is set to `YES`. ### Color Schemes Methods ###### **Note**: *Due to the limited number of flat colors currently available, color schemes may return results that reuse certain flat colors. Because of this redundancy, we have provided an option to return either a flat color scheme or a non-flat color scheme until more flat colors are added to the inventory.* The initial color can be either a non-flat color or flat color. Chameleon will return an `NSArray` of 5 `UIColors` in which the original color will be the third object of the scheme. This allows for Chameleon to designate the colors of the color scheme (2 colors counter-clockwise and 2 clockwise from the initial color), and thus, the chosen colors are aligned specifically in that order. #### Analogous Color Scheme An analogous color scheme uses three adjacent colors on the color wheel. According to Wikipedia, it’s best used with either warm or cool colors, creating a cohesive collection with certain temperature qualities as well as proper color harmony; however, this particular scheme lacks contrast and is less vibrant than complementary schemes. Within the scheme, choose one color to dominate and two to support. The remaining two colors should be used (along with black, white or gray) as accents. #### Complementary Color Scheme A complementary color scheme uses opposite colors on the color wheel. To put into slightly more technical terms, they are two colors that, when combined, produce a neutral color. Complementary colors are tricky to use extensively, but work well when you want a point of emphasis. Complementary colors are generally not favorable to use for text. #### Triadic Color Scheme A triadic scheme uses evenly spaced colors on the color wheel. The colors tend to be richly vivid and offer a higher degree of contrast while, at the same time, retain color harmony. Let one color dominate and use the two others for accent. #### Getting Colors in a Color Scheme To retrieve an array of colors, first make sure to initialize an NSMutableArray (in case you want to use the same array to replace with different colors later): ##### Normal Convention: ###### Objective-C ``` objective-c NSMutableArray *colorArray = [NSMutableArray alloc] initWithArray:[NSArray arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme]]; ``` ###### Swift ``` swift var colorArray = NSArray(ofColorsWithColorScheme:ColorScheme, with:UIColor!, flatScheme:Bool) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c NSMutableArray *colorArray = [[NSMutableArray alloc] initWithArray:ColorScheme(colorSchemeType, color, isFlatScheme)]; ``` ###### Swift ``` swift var colorArray = ColorSchemeOf(colorSchemeType, color, isFlatScheme) ``` ##### Example: Assuming you want to generate an analogous color scheme for the light shade of Flat Red, perform the following method call: ##### Normal Convention: ###### Objective-C ``` objective-c NSMutableArray *colorArray = [NSMutableArray alloc] initWithArray:[NSArray arrayOfColorsWithColorScheme:ColorSchemeAnalogous with:[UIColor flatRedColor] flatScheme:YES]]; ``` ###### Swift ``` swift var colorArray = NSArray(ofColorsWithColorScheme:ColorScheme.Analogous, with:UIColor.flatRed, flatScheme:true) ``` ##### Chameleon Shorthand: ###### Objective-C ``` objective-c NSMutableArray *colorArray = [[NSMutableArray alloc] initWithArray:ColorScheme(ColorSchemeAnalogous, FlatRed, YES)]; ``` ###### Swift ``` swift var colorArray = ColorSchemeOf(ColorScheme.Analogous, FlatRed(), true) ``` You can then retrieve each individual color the same way you would normally retrieve any object from an array: ###### Objective-C ```objective-c UIColor *firstColor = colorArray[0]; ``` ###### Swift ``` swift var firstColor = colorArray[0] as! UIColor ``` ### Theme Methods With Chameleon, you can now specify a global color theme with simply one line of code (It even takes care of dealing with the status bar style as well)! Here's one of three methods to get you started. `ContentStyle` allows you to decide whether text and a few other elements should be white, black, or whichever contrasts more over any UI element's `backgroundColor`. To set a global theme, you can do the following in your app delegate: ##### Normal Convention: ###### Objective-C ``` objective-c [Chameleon setGlobalThemeUsingPrimaryColor:(UIColor *)color withContentStyle:(UIContentStyle)contentStyle]; ``` But what if you want a different theme for a specific `UIViewController?` No problem, Chameleon allows you to override the global theme in any `UIViewController` and `UINavigationController`, by simply doing the following: ##### Normal Convention: ###### Objective-C ```objective-c //This would go in the controller you specifically want to theme differently [self setThemeUsingPrimaryColor:FlatMint withSecondaryColor:FlatBlue andContentStyle:UIContentStyleContrast]; ``` ###### **Note:** In order for the status bar style to automatically be set using a theme, you need to make sure that the *View controller-based status bar appearance* key in **Info.plist** is set to `NO`. #### Navigation Bar Hairline ![No Hairline](http://i.imgur.com/tjwx53y.png) As of `2.0.3` the navigation bar hairline view is no longer hidden by default. However, if you're seeking a true flat look (like the image above), you can hide the hairline at the bottom of the navigation bar by doing the following: ###### Objective-C ```objective-c [self.navigationController setHidesNavigationBarHairline:YES]; //or self.navigationController.hidesNavigationBarHairline = YES; ``` ###### Swift ```swift self.navigationController?.hidesNavigationBarHairline = true ``` ## 👑 Author Chameleon was developed by **Vicc Alexander** [(@ViccsMind)](https://twitter.com/viccsmind) in 2014 using Objective-C. In 2015, full Swift support was implemented by [@Bre7](https://github.com/bre7). Currently, it is being maintained by both [@ViccAlexander](https://github.com/ViccAlexander) and [@Bre7](https://github.com/bre7). ## 📝 To Do List * ~~CocoaPods Support~~ ![1.0.1](http://i.imgur.com/8Li5aRR.png) * ~~Table of Contents~~ ![1.0.1](http://i.imgur.com/8Li5aRR.png) * ~~Storyboard Color Picker Add-On~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) * ~~Xcode In-App Documentation~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) * ~~Switch from RGB values over to HSB and LAB~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) * ~~Gradient Colors~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) * ~~Update GradientStyle & ShadeStyle Syntax~~ ![1.1.1](http://i.imgur.com/AHxj8Rb.png) * ~~Add Radial Gradient Support~~ ![1.1.1](http://i.imgur.com/AHxj8Rb.png) * ~~Fix Swift Conflict with `initWithArray:for:flatScheme:` method~~ ![1.1.12](http://i.imgur.com/7NrZ7yx.png) * ~~Swift Support~~ ![1.1.3](http://i.imgur.com/WgpBlLo.png) * ~~Color Scheme From Images~~ ![2.0.0](http://i.imgur.com/HdE8kjQ.png) * ~~UIAppearance Convenience Methods~~ ![2.0.0](http://i.imgur.com/HdE8kjQ.png) * ~~Add option to hide `NavigationBar` hairline~~ ![2.0.3](http://i.imgur.com/DmlOKPJ.png) * ~~Add support for App Extensions hairline~~ ![2.2.0](http://i.imgur.com/z6575IT.png) * Add Swift Support for Random Colors * Allow Gradient Colors to Adapt To Frame Changes ## 📄 Change Log ### See [Changelog.md](https://github.com/ViccAlexander/Chameleon/blob/master/CHANGELOG.md) 👀