├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── Chameleon.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── Chameleon.xcscheme ├── Chameleon ├── Chameleon.h └── Info.plist ├── 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 │ │ └── Demo-1.png │ ├── Contents.json │ ├── SampleImageOne.imageset │ │ ├── Contents.json │ │ └── SampleImageOne-1.png │ ├── SampleImageTwo.imageset │ │ ├── Contents.json │ │ └── SampleImageTwo-1.png │ ├── first.imageset │ │ ├── Contents.json │ │ └── first.pdf │ ├── logo.imageset │ │ ├── Contents.json │ │ └── logo@2x.png │ └── second.imageset │ │ ├── Contents.json │ │ └── second.pdf ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── FirstViewController.swift ├── Info.plist └── SecondViewController.swift ├── ChameleonDemo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.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 /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ====== 2 | Read this before submitting a new report ;) 3 | 4 | * Use the search function to find similar bugs before submitting a new one. 5 | * Bug related to Global theming ? Check #98 for a workaround or #74 #102 #153 #161. 6 | 7 | 8 | DELETE THIS TEXT BEFORE SUBMITING A NEW ISSUE. 9 | ====== 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/ 2 | 3 | ## Build generated 4 | build/ 5 | DerivedData 6 | 7 | ## Various settings 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | 18 | ## Other 19 | *.xccheckout 20 | *.moved-aside 21 | *.xcuserstate 22 | *.xcscmblueprint 23 | 24 | ## Build generated 25 | build/ 26 | DerivedData 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | 32 | # CocoaPods 33 | # 34 | # We recommend against adding the Pods directory to your .gitignore. However 35 | # you should judge for yourself, the pros and cons are mentioned at: 36 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 37 | # 38 | Pods/ 39 | 40 | # Carthage 41 | # 42 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 43 | # Carthage/Checkouts 44 | 45 | Carthage/Build 46 | Carthage.checkout 47 | Carthage.build 48 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 📄 Change Log 2 | 3 | ### 2.0.5 4 | 5 | * Theme Support for UIImagePickerController (#83) 6 | * Objective-C Demo Project 7 | * Fixed Erroneous Swift Method Naming Convention Warnings 8 | * Bumped up the minimum version of iOS to `8.0`. 9 | * Fixed `If-Else` Statement Logic (#48) 10 | * Removed cast for `calloc` (#76). 11 | 12 | ### 2.0.4 13 | 14 | * Minor Fixes. 15 | * Simplified `arrayOfColorsWithColorScheme` (#68) 16 | * `colorWithFlatVersionFrom` alpha bug fix (#69) 17 | 18 | ### 2.0.3 19 | 20 | * Added `hidesNavigationBarHairline` boolean to UINavigationController, and by default it is now set to `NO`. (#64) 21 | * Improved Quick-Look Documentation for Theme Methods 22 | 23 | ### 2.0.2 24 | 25 | * Carthage support added. (By [@bre7](https://github.com/bre7)) 26 | * Demo project added. (By [@bre7](https://github.com/bre7)) 27 | * Shields added to `README`. (By [@bre7](https://github.com/bre7)) 28 | * Fixed *'Wrong Navigation Bar Color'* bug. ([#51](https://github.com/ViccAlexander/Chameleon/issues/51)) (By [@bre7](https://github.com/bre7)) 29 | * Fixed *'Flatten'* bug. ([#53](https://github.com/ViccAlexander/Chameleon/issues/53)) (By [@bre7](https://github.com/bre7)) 30 | * Fixed *'EXC_BAD_ACCESS Error'* issue. ([#57](https://github.com/ViccAlexander/Chameleon/issues/57)) (By [@bre7](https://github.com/bre7)) 31 | * Several swift functions were made public. (By [@dexter505](https://github.com/dexter505)) 32 | 33 | ### 2.0.1 34 | 35 | * Fixed *'ColorWithFlatVersionOf'* bug. ([#50](https://github.com/ViccAlexander/Chameleon/pull/50)) (By [@bre7](https://github.com/bre7)) 36 | 37 | ### 2.0.0 38 | 39 | * Added support for hex colors, colors from images, themes, and lighten and darken by percentage methods. (By [@ViccAlexander](https://github.com/ViccAlexander)) 40 | 41 | ###### Added Methods 42 | 43 | **Chameleon.h** 44 | 45 | * `+ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle;` 46 | * `+ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle;` 47 | * `+ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle;` 48 | 49 | **NSArray+Chameleon.h** 50 | 51 | * `+ (NSArray *)arrayOfColorsFromImage:(UIImage *)image withFlatScheme (BOOL)isFlatScheme;` 52 | 53 | **UIColor+Chameleon.h** 54 | 55 | * `+ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image;` 56 | * `+ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha;` 57 | * `+ (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha;` 58 | * `+ (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha;` 59 | * `+ (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat alpha:(CGFloat)alpha;` 60 | * `+ (UIColor *)colorWithFlatVersionOf:(UIColor *)color withAlpha:(CGFloat)alpha;` 61 | * `+ (UIColor *)colorWithHexString:(NSString *)string;` 62 | * `+ (UIColor *)colorWithHexString:(NSString *)string withAlpha:(CGFloat)alpha;` 63 | * `- (UIColor *)flatten;` 64 | * `- (UIColor *)darkenByPercentage:(CGFloat)percentage;` 65 | * `- (UIColor *)lightenByPercentage:(CGFloat)percentage;` 66 | 67 | **UINavigationController+Chameleon.h** 68 | 69 | * `- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;` 70 | * `- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle;` 71 | * `- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor andContentStyle:(UIContentStyle)contentStyle;` 72 | * `setThemeUsingPrimaryColor:(UIColor *)primaryColor withSecondaryColor:(UIColor *)secondaryColor usingFontName:(NSString *)fontName andContentStyle:(UIContentStyle)contentStyle;` 73 | * `- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;` 74 | 75 | 76 | ###### Deprecated Methods 77 | 78 | **NSArray+Chameleon.h** 79 | 80 | * ~~`+ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme `~~ 81 | 82 | > Replaced with: `+ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme usingColor:(UIColor *)color withFlatScheme:(BOOL)isFlatScheme;` 83 | 84 | **UIViewController+Chameleon.h** 85 | 86 | * ~~`- (void)flatify;`~~ 87 | * ~~`- (void)flatifyAndContrast;`~~ 88 | 89 | ###### Added Macros 90 | * `AverageColorFromImage(image)` 91 | * `AverageColorFromImageWithAlpha(image, alpha)` 92 | * `RandomFlatColorWithShadeAndAlpha(shade, alpha)` 93 | * `ColorsWithScheme(colorSchemeType, color, isFlatScheme)` 94 | * `ComplementaryFlatColorWithAlpha(color, alpha)` 95 | * `ContrastColorWithAlpha(backgroundColor, returnFlat, alpha)` 96 | * `HexColor(hexString)` 97 | * `HexColorWithAlpha(hexString, alpha)` 98 | * `RandomFlatColorWithShadeAndAlpha(shade, alpha)` 99 | * `ColorsFromImage(image, isFlatScheme)` 100 | 101 | ######Deprecated 102 | * `ColorsWithScheme(colorSchemeType, color, isFlatScheme)` 103 | 104 | > Replaced with: `ColorsWithScheme(colorSchemeType, color, isFlatScheme)` 105 | 106 | ### 1.2.1 107 | • Added cocoapods support for Swift 2 *(Thanks to [**@bre7**](https://github.com/bre7))*. 108 | 109 | ### 1.2.0 110 | • Fixed cocoapods installation error [#30](https://github.com/ViccAlexander/Chameleon/issues/30). 111 | • Updated Swift syntax to Swift 1.2 *(Fixed by [**@peacemoon**](https://github.com/peacemoon))*. 112 | • Split Objective-C & Swift Files into separate folders to keep files better organized. 113 | • Renamed `Constants.swift` to `ChameleonShorthand.swift` 114 | 115 | ###### Deprecated Methods 116 | 117 | * ~~`FlatVersionOfColor(color)`~~ 118 | * ~~`ColorScheme(colorSchemeType: ColorScheme, color: UIColor, isFlatScheme: Bool)`~~ 119 | 120 | Replaced with: `ColorSchemeOf(colorSchemeType: ColorScheme, color: UIColor, isFlatScheme: Bool)` due to naming constraints. 121 | 122 | ### 1.1.3 123 | • Chameleon shorthand is now supported in Swift. *(Thanks to [**@bre7**](https://github.com/bre7))*. 124 | • Fixed Small Syntax Typo. *(Fixed by [**@ddwang**](https://github.com/ddwang))*. 125 | • Fixed issue where `-colorWithRandomFlatColorOfShadeStyle` always returns random color of `UIShadeStyleLight` *(Fixed by [**@smokyonion**](https://github.com/smokyonion))*. 126 | • 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))*. 127 | • Removed warnings regarding the absolute value function `fabsf` *(Fixed by [**@jherran**](https://github.com/jherran))*. 128 | • Fixed the *`UIColor+Chameleon.m:444:13: code will never be executed*`, error state *(Fixed by [**@jherran**](https://github.com/jherran))*. 129 | 130 | 131 | ### 1.1.2 132 | • Updated Copyright in all files and launch images 133 | • Added Launch Image in example project for iPhone 6 & iPhone 6 Plus 134 | • Replaced the reserved word `for` with the word `with` in `arrayOfColorsWithColorScheme` *(Fixed by [**@sfader**](https://github.com/sfader))*. 135 | 136 | ###### Deprecated Methods 137 | * ~~`initWithArray:for:flatScheme:`~~ 138 | 139 | Replaced with: `initWithArray:with:flatScheme:` 140 | 141 | ### 1.1.1 142 | * ```ShadeStyle``` is now ```UIShadeStyle``` 143 | * ```GradientStyle``` is now ```UIGradientStyle``` 144 | * ```light``` is now ```UIShadeStyleLight``` 145 | * ```dark``` is now ```UIShadeStyleDark``` 146 | * ```linearGradientLeftToRight``` is now ```UIGradientStyleLeftToRight``` 147 | * ```linearGradientTopToBottom``` is now ```UIGradientStyleTopToBottom``` 148 | * Added: ```UIGradientStyleRadial``` 149 | 150 | ### 1.1.0 151 | * Added Gradient Colors 152 | * Added Storyboard Palette Add-on 153 | * Added Xcode Quick Help Documentation Support 154 | * Switched from RGB colorspace to HSB & LAB colorspaces (closer to human perception) 155 | * Implemented `ContrastingColor` which supports all alphas and has additional support for non-flat and flat colors 156 | * Changed Color difference algorithm so that it now uses CIE:2000 formula 157 | * Changed `RandomFlatColors` from enum to nsarray values 158 | * Edited `RandomFlatColor` so that it will no longer spit out the same color back to back 159 | * Switched complementary and triadic fourth and fifth colors order. 160 | * New Macro: `ClearColor` 161 | 162 | ###### Deprecated Methods 163 | * ~~`colorWithContrastingBlackOrWhiteColorOn:`~~ 164 | 165 | Replaced with: `colorWithContrastingBlackOrWhiteColorOn:isFlat:` 166 | 167 | ###### Deprecated Macros 168 | * ~~`ContrastingColorOf(backgroundColor)`~~ 169 | 170 | Replaced with: `ContrastingColorOf(backgroundColor, isFlat)` 171 | 172 | * ~~`ComplementaryColorOf(color)`~~ 173 | 174 | Replaced with: `ComplementaryFlatColorOf(color)` 175 | 176 | * ~~`RandomColorWithShade(shade)`~~ 177 | 178 | Replaced with: `RandomFlatColorWithShade(shade)` 179 | 180 | ### 1.0.1 181 | * Added Table of Contents 182 | * Fixed a couple of spelling errors 183 | * Extra '#define' deleted *(Fixed by [**@cascio**](https://github.com/cascio))*. 184 | * Imported UIKit in ChameleonStatusBar.h and NSArray+Chameleon.h *(Fixed by [**@jmhooper**](https://github.com/jmhooper))*. 185 | -------------------------------------------------------------------------------- /Chameleon.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chameleon.xcodeproj/xcshareddata/xcschemes/Chameleon.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 72 | 73 | 74 | 75 | 77 | 78 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Chameleon/Chameleon.h: -------------------------------------------------------------------------------- 1 | // 2 | // Chameleon.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 9/24/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Chameleon. 12 | FOUNDATION_EXPORT double ChameleonVersionNumber; 13 | 14 | //! Project version string for Chameleon. 15 | FOUNDATION_EXPORT const unsigned char ChameleonVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | #import "Chameleon_.h" 20 | 21 | #import "UIButton+Chameleon.h" 22 | #import "UILabel+Chameleon.h" 23 | #import "UIColor+ChameleonPrivate.h" 24 | #import "UIImage+ChameleonPrivate.h" 25 | #import "UIView+ChameleonPrivate.h" 26 | #import "UIAppearance+Swift.h" 27 | 28 | #import "NSArray+Chameleon.h" 29 | #import "UIColor+Chameleon.h" 30 | #import "UINavigationController+Chameleon.h" 31 | #import "UIViewController+Chameleon.h" 32 | -------------------------------------------------------------------------------- /Chameleon/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.6 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ChameleonDemo-Objc 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | @import Chameleon; 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ChameleonDemo-Objc 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | //Set global theme 21 | [Chameleon setGlobalThemeUsingPrimaryColor:FlatMint withSecondaryColor:FlatBlue andContentStyle:UIContentStyleContrast]; 22 | 23 | 24 | return YES; 25 | } 26 | 27 | - (void)applicationWillResignActive:(UIApplication *)application { 28 | // 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. 29 | // 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. 30 | } 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 2.0.6 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UIViewControllerBasedStatusBarAppearance 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ChameleonDemo-Objc 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | @import Chameleon; 11 | 12 | @interface ViewController : UIViewController 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ChameleonDemo-Objc 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | 19 | //Super 20 | [super viewDidLoad]; 21 | 22 | //Set View Background 23 | self.view.backgroundColor = FlatYellow; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | 28 | //Super 29 | [super didReceiveMemoryWarning]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ChameleonDemo-ObjC/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ChameleonDemo-Objc 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ChameleonDemo-Swift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ChameleonDemo 4 | // 5 | // Created by Wei Huang on 5/5/17. 6 | // Copyright © 2017 Wei Huang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | return true 19 | } 20 | 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Demo-1.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "idiom" : "iphone", 41 | "size" : "60x60", 42 | "scale" : "3x" 43 | }, 44 | { 45 | "idiom" : "ios-marketing", 46 | "size" : "1024x1024", 47 | "scale" : "1x" 48 | } 49 | ], 50 | "info" : { 51 | "version" : 1, 52 | "author" : "xcode" 53 | } 54 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/AppIcon.appiconset/Demo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/ChameleonDemo-Swift/Assets.xcassets/AppIcon.appiconset/Demo-1.png -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/SampleImageOne.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "SampleImageOne-1.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/SampleImageOne.imageset/SampleImageOne-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/ChameleonDemo-Swift/Assets.xcassets/SampleImageOne.imageset/SampleImageOne-1.png -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/SampleImageTwo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "SampleImageTwo-1.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/SampleImageTwo.imageset/SampleImageTwo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/ChameleonDemo-Swift/Assets.xcassets/SampleImageTwo.imageset/SampleImageTwo-1.png -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/first.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "first.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/first.imageset/first.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/ChameleonDemo-Swift/Assets.xcassets/first.imageset/first.pdf -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/logo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "logo@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/logo.imageset/logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/ChameleonDemo-Swift/Assets.xcassets/logo.imageset/logo@2x.png -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/second.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "second.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Assets.xcassets/second.imageset/second.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/ChameleonDemo-Swift/Assets.xcassets/second.imageset/second.pdf -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /ChameleonDemo-Swift/FirstViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FirstViewController.swift 3 | // ChameleonDemo 4 | // 5 | // Created by Wei Huang on 5/5/17. 6 | // Copyright © 2017 Wei Huang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Chameleon 11 | 12 | class FirstViewController: UITableViewController { 13 | 14 | @IBOutlet weak var randomFlatColorLabel: UILabel! 15 | 16 | @IBOutlet weak var complementaryFlatColorLabel: UILabel! 17 | 18 | @IBOutlet weak var contrastFlatColorLabel: UILabel! 19 | 20 | @IBOutlet weak var flatteningNonFlatColorLabel: UILabel! 21 | 22 | @IBOutlet weak var beforeFlatteningColorLabel: UILabel! 23 | 24 | @IBOutlet weak var lighterColorLabel: UILabel! 25 | 26 | @IBOutlet weak var darkerColorLabel: UILabel! 27 | 28 | @IBOutlet weak var gradientColorLabel: UILabel! 29 | 30 | @IBOutlet weak var gradientComponentColorOneLabel: UILabel! 31 | 32 | @IBOutlet weak var gradientComponentColorTwoLabel: UILabel! 33 | 34 | @IBOutlet weak var gradientComponentColorThreeLabel: UILabel! 35 | 36 | @IBOutlet weak var gradientWithContrastLabel: UILabel! 37 | 38 | @IBOutlet weak var refreshButton: UIBarButtonItem! 39 | 40 | // MARK: Life cycles 41 | override func viewDidLoad() { 42 | super.viewDidLoad() 43 | // Do any additional setup after loading the view, typically from a nib. 44 | initChameleonColors() 45 | 46 | // Hide nav bar hairline 47 | self.navigationController?.hidesNavigationBarHairline = true 48 | } 49 | 50 | override func viewWillAppear(_ animated: Bool) { 51 | // initChameleonColors() 52 | } 53 | 54 | 55 | // MARK: Chameleon related 56 | func initChameleonColors() { 57 | 58 | let randomFlatColor = UIColor.randomFlat 59 | let randomFlatColorContract = ContrastColorOf(randomFlatColor, returnFlat: true) 60 | // Nav bar 61 | navigationController?.navigationBar.barTintColor = randomFlatColor 62 | navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: randomFlatColorContract] 63 | // Tab bar 64 | tabBarController?.tabBar.barTintColor = randomFlatColor 65 | tabBarController?.tabBar.tintColor = randomFlatColorContract 66 | // Refresh button 67 | refreshButton.tintColor = randomFlatColorContract 68 | // Random flat color 69 | randomFlatColorLabel.text = "Aa \u{25A0}" 70 | randomFlatColorLabel.textColor = randomFlatColor 71 | // Complementary flat color 72 | complementaryFlatColorLabel.text = "Aa \u{25A0}" 73 | complementaryFlatColorLabel.textColor = ComplementaryFlatColorOf(randomFlatColor) 74 | // Contrast flat color 75 | contrastFlatColorLabel.text = "Aa \u{25A0}" 76 | contrastFlatColorLabel.textColor = ContrastColorOf(randomFlatColor, returnFlat: true) 77 | // Flattening non-flat color 78 | let randomColor = generateRandomColor() // custom method, not part of Chameleon 79 | flatteningNonFlatColorLabel.text = "Aa \u{25A0}" 80 | flatteningNonFlatColorLabel.textColor = randomColor.flatten() 81 | beforeFlatteningColorLabel.text = "Aa \u{25A0}" 82 | beforeFlatteningColorLabel.textColor = randomColor 83 | // Lighter color > not yet reliable 84 | lighterColorLabel.text = "Aa \u{25A0}" 85 | lighterColorLabel.textColor = randomFlatColor.lighten(byPercentage: 0.5) 86 | // Darker color > not yet reliable 87 | darkerColorLabel.text = "Aa \u{25A0}" 88 | darkerColorLabel.textColor = randomFlatColor.darken(byPercentage: 0.5) 89 | // Gradient color 90 | let firstRandomColor = UIColor.randomFlat 91 | let secondRandomColor = UIColor.randomFlat 92 | let thirdRandomColor = UIColor.randomFlat 93 | let gradientColor = GradientColor(.leftToRight, frame: gradientColorLabel.frame, colors: [firstRandomColor, secondRandomColor, thirdRandomColor]) 94 | let gradientColorLargeFrame = GradientColor(.leftToRight, frame: gradientWithContrastLabel.frame, colors: [firstRandomColor, secondRandomColor, thirdRandomColor]) 95 | gradientColorLabel.text = "Aa \u{25A0}" 96 | gradientColorLabel.textColor = gradientColor 97 | // Gradient backgorund with contrast text 98 | gradientComponentColorOneLabel.text = "\u{25A0}" 99 | gradientComponentColorOneLabel.textColor = firstRandomColor 100 | gradientComponentColorTwoLabel.text = "\u{25A0}" 101 | gradientComponentColorTwoLabel.textColor = secondRandomColor 102 | gradientComponentColorThreeLabel.text = "\u{25A0}" 103 | gradientComponentColorThreeLabel.textColor = thirdRandomColor 104 | gradientWithContrastLabel.text = "FANCY COLOR" 105 | gradientWithContrastLabel.textColor = ContrastColorOf(gradientColorLargeFrame, returnFlat: true) 106 | gradientWithContrastLabel.backgroundColor = gradientColorLargeFrame 107 | gradientWithContrastLabel.layer.masksToBounds = true 108 | gradientWithContrastLabel.layer.cornerRadius = 8 109 | } 110 | 111 | // Refresh colors 112 | @IBAction func refreshButtonAction(_ sender: Any) { 113 | initChameleonColors() 114 | } 115 | 116 | // Generate a random color 117 | func generateRandomColor() -> UIColor { 118 | let red = Float(arc4random_uniform(256))/255.0 119 | let green = Float(arc4random_uniform(256))/255.0 120 | let blue = Float(arc4random_uniform(256))/255.0 121 | 122 | return UIColor(colorLiteralRed: red, green: green, blue: blue, alpha: 1.0) 123 | } 124 | } 125 | 126 | 127 | -------------------------------------------------------------------------------- /ChameleonDemo-Swift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ChameleonDemo-Swift/SecondViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.swift 3 | // ChameleonDemo 4 | // 5 | // Created by Wei Huang on 5/5/17. 6 | // Copyright © 2017 Wei Huang. All rights reserved. 7 | // 8 | // - Attribution: image #1 - vecteezy.com 9 | // - Attribution: image #1 - 500px.com 10 | 11 | import UIKit 12 | import Chameleon 13 | 14 | class SecondViewController: UITableViewController { 15 | @IBOutlet weak var sampleOneImageView: UIImageView! 16 | 17 | @IBOutlet weak var sampleOneAverageColorLabel: UILabel! 18 | 19 | @IBOutlet weak var sampleOneComponentColorOneLabel: UILabel! 20 | 21 | @IBOutlet weak var sampleOneComponentColorTwoLabel: UILabel! 22 | 23 | @IBOutlet weak var sampleOneComponentColorThreeLabel: UILabel! 24 | 25 | @IBOutlet weak var sampleOneComponentColorFourLabel: UILabel! 26 | 27 | @IBOutlet weak var sampleOneComponentColorFiveLabel: UILabel! 28 | 29 | @IBOutlet weak var sampleTwoImageView: UIImageView! 30 | 31 | @IBOutlet weak var sampleTwoAverageColorLabel: UILabel! 32 | 33 | @IBOutlet weak var sampleTwoComponentColorOneLabel: UILabel! 34 | 35 | @IBOutlet weak var sampleTwoComponentColorTwoLabel: UILabel! 36 | 37 | @IBOutlet weak var sampleTwoComponentColorThreeLabel: UILabel! 38 | 39 | @IBOutlet weak var sampleTwoComponentColorFourLabel: UILabel! 40 | 41 | @IBOutlet weak var sampleTwoComponentColorFiveLabel: UILabel! 42 | 43 | override func viewDidLoad() { 44 | super.viewDidLoad() 45 | navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: tabBarController?.tabBar.tintColor ?? UIColor.gray] 46 | navigationController?.navigationBar.barTintColor = tabBarController?.tabBar.barTintColor ?? UIColor.lightGray 47 | sampleOneImageView.image = #imageLiteral(resourceName: "SampleImageOne") 48 | sampleTwoImageView.image = #imageLiteral(resourceName: "SampleImageTwo") 49 | sampleOneImageView.layer.masksToBounds = true 50 | sampleTwoImageView.layer.masksToBounds = true 51 | sampleOneImageView.layer.cornerRadius = 8 52 | sampleTwoImageView.layer.cornerRadius = 8 53 | initChameleon() 54 | } 55 | 56 | override func viewWillAppear(_ animated: Bool) { 57 | navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: tabBarController?.tabBar.tintColor ?? UIColor.gray] 58 | navigationController?.navigationBar.barTintColor = tabBarController?.tabBar.barTintColor ?? UIColor.lightGray 59 | } 60 | 61 | // Chameleon related 62 | func initChameleon() { 63 | let sampleOneImageColors = ColorsFromImage(#imageLiteral(resourceName: "SampleImageOne"), withFlatScheme: true) 64 | print(sampleOneImageColors.count) 65 | let sampleTwoImageColors = ColorsFromImage(#imageLiteral(resourceName: "SampleImageTwo"), withFlatScheme: true) 66 | print(sampleTwoImageColors.count) 67 | let sampleOneImageAverageColor = AverageColorFromImage(#imageLiteral(resourceName: "SampleImageOne")) 68 | let sampleTwoImageAverageColor = AverageColorFromImage(#imageLiteral(resourceName: "SampleImageTwo")) 69 | 70 | sampleOneAverageColorLabel.text = "Aa \u{25A0}" 71 | sampleOneAverageColorLabel.textColor = sampleOneImageAverageColor 72 | 73 | sampleTwoAverageColorLabel.text = "Aa \u{25A0}" 74 | sampleTwoAverageColorLabel.textColor = sampleTwoImageAverageColor 75 | 76 | sampleOneComponentColorOneLabel.text = "\u{25A0}" 77 | sampleOneComponentColorOneLabel.textColor = sampleOneImageColors[0] 78 | sampleOneComponentColorTwoLabel.text = "\u{25A0}" 79 | sampleOneComponentColorTwoLabel.textColor = sampleOneImageColors[1] 80 | sampleOneComponentColorThreeLabel.text = "\u{25A0}" 81 | sampleOneComponentColorThreeLabel.textColor = sampleOneImageColors[2] 82 | sampleOneComponentColorFourLabel.text = "\u{25A0}" 83 | sampleOneComponentColorFourLabel.textColor = sampleOneImageColors[3] 84 | sampleOneComponentColorFiveLabel.text = "\u{25A0}" 85 | sampleOneComponentColorFiveLabel.textColor = sampleOneImageColors[4] 86 | 87 | sampleTwoComponentColorOneLabel.text = "\u{25A0}" 88 | sampleTwoComponentColorOneLabel.textColor = sampleOneImageColors[0] 89 | sampleTwoComponentColorTwoLabel.text = "\u{25A0}" 90 | sampleTwoComponentColorTwoLabel.textColor = sampleOneImageColors[1] 91 | sampleTwoComponentColorThreeLabel.text = "\u{25A0}" 92 | sampleTwoComponentColorThreeLabel.textColor = sampleOneImageColors[2] 93 | sampleTwoComponentColorFourLabel.text = "\u{25A0}" 94 | sampleTwoComponentColorFourLabel.textColor = sampleOneImageColors[3] 95 | sampleTwoComponentColorFiveLabel.text = "\u{25A0}" 96 | sampleTwoComponentColorFiveLabel.textColor = sampleOneImageColors[4] 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /ChameleonDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ChameleonDemo 4 | // 5 | // Created by Vicc Alexander on 9/25/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Chameleon 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { 18 | 19 | Chameleon.setGlobalThemeUsingPrimaryColor(.flatPlum, 20 | withSecondaryColor: .flatBlue, 21 | andContentStyle: .contrast) 22 | 23 | return true 24 | } 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /ChameleonDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ChameleonDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ChameleonDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /ChameleonDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 2.0.6 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | UIViewControllerBasedStatusBarAppearance 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ChameleonDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ChameleonDemo 4 | // 5 | // Created by Vicc Alexander on 9/25/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Chameleon 11 | 12 | class ViewController: UIViewController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | 17 | view.backgroundColor = GradientColor(UIGradientStyle.leftToRight, frame: view.frame, colors: [UIColor.black, UIColor.yellow]) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ChameleonFramework.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ChameleonFramework" 3 | s.version = "2.1.0" 4 | s.summary = "Color Framework for iOS (Obj-C & Swift)" 5 | s.homepage = "https://github.com/ViccAlexander/Chameleon" 6 | s.screenshots = "https://camo.githubusercontent.com/bde5aa6ee0e1feec044d184a735da8024c60c04c/687474703a2f2f692e696d6775722e636f6d2f427771486842342e706e67" 7 | 8 | s.license = { :type => "MIT", :file => "LICENSE.md" } 9 | s.author = "Vicc Alexander" 10 | s.social_media_url = "http://twitter.com/ViccsMind" 11 | s.platform = :ios 12 | s.ios.deployment_target = '8.0' 13 | s.source = { :git => "https://github.com/ViccAlexander/Chameleon.git", 14 | :tag => s.version.to_s } 15 | 16 | s.public_header_files = 'Pod/Classes/Objective-C/**/*.h' 17 | s.frameworks = 'UIKit', 'QuartzCore', 'CoreGraphics' 18 | 19 | s.default_subspecs = 'Default' 20 | 21 | s.subspec 'Default' do |ss| 22 | ss.source_files = 'Pod/Classes/Objective-C/**/*.{h,m}' 23 | end 24 | 25 | s.subspec 'Swift' do |ss| 26 | ss.ios.deployment_target = '8.0' 27 | ss.source_files = 'Pod/Classes/Swift/ChameleonShorthand.swift' 28 | ss.dependency 'ChameleonFramework/Default' 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /Extras/Chameleon.clr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/Extras/Chameleon.clr -------------------------------------------------------------------------------- /Extras/Chameleon.dmg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/Extras/Chameleon.dmg -------------------------------------------------------------------------------- /Extras/Chameleon.sketchpalette: -------------------------------------------------------------------------------- 1 | {"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"]} -------------------------------------------------------------------------------- /Extras/Chameleon_Photoshop.aco: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/Extras/Chameleon_Photoshop.aco -------------------------------------------------------------------------------- /Extras/Chameleon_v2.clr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicc/chameleon/6dd284bde21ea2e7f9fd89bc36f40df16e16369d/Extras/Chameleon_v2.clr -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ##The MIT License (MIT) 2 | 3 | > Copyright (c) 2014-2015 Vicc Alexander 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | 12 | > The above copyright notice and this permission notice shall be included in all 13 | > copies or substantial portions of the Software. 14 | 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | > SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/Chameleon.h: -------------------------------------------------------------------------------- 1 | // 2 | // Chameleon.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 9/24/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Chameleon. 12 | FOUNDATION_EXPORT double ChameleonVersionNumber; 13 | 14 | //! Project version string for Chameleon. 15 | FOUNDATION_EXPORT const unsigned char ChameleonVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | #import "Chameleon_.h" 20 | 21 | #import "UIButton+Chameleon.h" 22 | #import "UILabel+Chameleon.h" 23 | #import "UIColor+ChameleonPrivate.h" 24 | #import "UIImage+ChameleonPrivate.h" 25 | #import "UIView+ChameleonPrivate.h" 26 | #import "UIAppearance+Swift.h" 27 | 28 | #import "NSArray+Chameleon.h" 29 | #import "UIColor+Chameleon.h" 30 | #import "UINavigationController+Chameleon.h" 31 | #import "UIViewController+Chameleon.h" 32 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/ChameleonConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 13 | * A contrasting status bar, intended for use on any backgrounds. 14 | * 15 | * @since 2.0 16 | */ 17 | extern const UIStatusBarStyle UIStatusBarStyleContrast; 18 | 19 | @interface ChameleonConstants : NSObject 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/ChameleonConstants.m: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "ChameleonConstants.h" 10 | 11 | const UIStatusBarStyle UIStatusBarStyleContrast = 100; 12 | 13 | @implementation ChameleonConstants 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/ChameleonEnums.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChameleonEnums.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/8/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #ifndef Chameleon_ChameleonEnums_h 10 | #define Chameleon_ChameleonEnums_h 11 | 12 | /** 13 | * Specifies how text-based UI elements and other content such as switch knobs, should be colored. 14 | * 15 | * @since 2.0 16 | */ 17 | 18 | typedef NS_ENUM(NSUInteger, UIContentStyle) { 19 | /** 20 | * Automatically chooses and colors text-based elements with the shade that best contrasts its @c backgroundColor. 21 | * 22 | * @since 2.0 23 | */ 24 | UIContentStyleContrast, 25 | /** 26 | * Colors text-based elements using a light shade. 27 | * 28 | * @since 2.0 29 | */ 30 | UIContentStyleLight, 31 | /** 32 | * Colors text-based elements using a light shade. 33 | * 34 | * @since 2.0 35 | */ 36 | UIContentStyleDark 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/ChameleonMacros.h: -------------------------------------------------------------------------------- 1 | 2 | // ChameleonMacros.h 3 | 4 | /* 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2014-2015 Vicc Alexander. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | #import "UIColor+Chameleon.h" 31 | 32 | #pragma mark - Light Shades Shorthand 33 | 34 | #define FlatBlack [UIColor flatBlackColor] 35 | #define FlatBlue [UIColor flatBlueColor] 36 | #define FlatBrown [UIColor flatBrownColor] 37 | #define FlatCoffee [UIColor flatCoffeeColor] 38 | #define FlatForestGreen [UIColor flatForestGreenColor] 39 | #define FlatGray [UIColor flatGrayColor] 40 | #define FlatGreen [UIColor flatGreenColor] 41 | #define FlatLime [UIColor flatLimeColor] 42 | #define FlatMagenta [UIColor flatMagentaColor] 43 | #define FlatMaroon [UIColor flatMaroonColor] 44 | #define FlatMint [UIColor flatMintColor] 45 | #define FlatNavyBlue [UIColor flatNavyBlueColor] 46 | #define FlatOrange [UIColor flatOrangeColor] 47 | #define FlatPink [UIColor flatPinkColor] 48 | #define FlatPlum [UIColor flatPlumColor] 49 | #define FlatPowderBlue [UIColor flatPowderBlueColor] 50 | #define FlatPurple [UIColor flatPurpleColor] 51 | #define FlatRed [UIColor flatRedColor] 52 | #define FlatSand [UIColor flatSandColor] 53 | #define FlatSkyBlue [UIColor flatSkyBlueColor] 54 | #define FlatTeal [UIColor flatTealColor] 55 | #define FlatWatermelon [UIColor flatWatermelonColor] 56 | #define FlatWhite [UIColor flatWhiteColor] 57 | #define FlatYellow [UIColor flatYellowColor] 58 | 59 | // --------------------------------------------------- 60 | 61 | #pragma mark - Dark Shades Shorthand 62 | 63 | #define FlatBlackDark [UIColor flatBlackDarkColor] 64 | #define FlatBlueDark [UIColor flatBlueDarkColor] 65 | #define FlatBrownDark [UIColor flatBrownDarkColor] 66 | #define FlatCoffeeDark [UIColor flatCoffeeDarkColor] 67 | #define FlatForestGreenDark [UIColor flatForestGreenDarkColor] 68 | #define FlatGrayDark [UIColor flatGrayDarkColor] 69 | #define FlatGreenDark [UIColor flatGreenDarkColor] 70 | #define FlatLimeDark [UIColor flatLimeDarkColor] 71 | #define FlatMagentaDark [UIColor flatMagentaDarkColor] 72 | #define FlatMaroonDark [UIColor flatMaroonDarkColor] 73 | #define FlatMintDark [UIColor flatMintDarkColor] 74 | #define FlatNavyBlueDark [UIColor flatNavyBlueDarkColor] 75 | #define FlatOrangeDark [UIColor flatOrangeDarkColor] 76 | #define FlatPinkDark [UIColor flatPinkDarkColor] 77 | #define FlatPlumDark [UIColor flatPlumDarkColor] 78 | #define FlatPowderBlueDark [UIColor flatPowderBlueDarkColor] 79 | #define FlatPurpleDark [UIColor flatPurpleDarkColor] 80 | #define FlatRedDark [UIColor flatRedDarkColor] 81 | #define FlatSandDark [UIColor flatSandDarkColor] 82 | #define FlatSkyBlueDark [UIColor flatSkyBlueDarkColor] 83 | #define FlatTealDark [UIColor flatTealDarkColor] 84 | #define FlatWatermelonDark [UIColor flatWatermelonDarkColor] 85 | #define FlatWhiteDark [UIColor flatWhiteDarkColor] 86 | #define FlatYellowDark [UIColor flatYellowDarkColor] 87 | 88 | // --------------------------------------------------- 89 | 90 | #pragma mark - Special Colors Shorthand 91 | 92 | #define RandomFlatColor [UIColor randomFlatColor] 93 | #define ClearColor [UIColor clearColor] 94 | 95 | // --------------------------------------------------- 96 | 97 | #pragma mark - UIColor Methods Shorthand 98 | 99 | #define AverageColorFromImage(image) [UIColor colorWithAverageColorFromImage:image] 100 | #define AverageColorFromImageWithAlpha(image, alpha) [UIColor colorWithAverageColorFromImage:image withAlpha:alpha] 101 | 102 | #define ComplementaryFlatColor(color) [UIColor colorWithComplementaryFlatColorOf:color] 103 | #define ComplementaryFlatColorWithAlpha(color, alpha) [UIColor colorWithComplementaryFlatColorOf:color withAlpha:alpha] 104 | 105 | #define ContrastColor(backgroundColor, returnFlat) [UIColor colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:returnFlat] 106 | #define ContrastColorWithAlpha(backgroundColor, returnFlat, alpha) [UIColor colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:returnFlat alpha:alpha] 107 | 108 | #define GradientColor(gradientStyle, frame, colors) [UIColor colorWithGradientStyle:gradientStyle withFrame:frame andColors:colors] 109 | 110 | #define HexColor(hexString) [UIColor colorWithHexString:hexString] 111 | #define HexColorWithAlpha(hexString, alpha) [UIColor colorWithHexString:hexString withAlpha:alpha] 112 | 113 | #define RandomFlatColorInArray(colors) [UIColor colorWithRandomColorInArray:colors] 114 | #define RandomFlatColorExcluding(colors) [UIColor colorWithRandomFlatColorExcludingColorsInArray:colors]; 115 | #define RandomFlatColorWithShade(shade) [UIColor colorWithRandomFlatColorOfShadeStyle:shade] 116 | #define RandomFlatColorWithShadeAndAlpha(shade, alpha) [UIColor colorWithRandomFlatColorOfShadeStyle:shade withAlpha:alpha] 117 | 118 | // --------------------------------------------------- 119 | 120 | #pragma mark - NSArray Shorthand 121 | 122 | #define ColorsWithScheme(colorSchemeType, color, isFlatScheme) [NSArray arrayOfColorsWithColorScheme:colorSchemeType usingColor:color withFlatScheme:isFlatScheme] 123 | #define ColorsFromImage(image, isFlatScheme) [NSArray arrayOfColorsFromImage:image withFlatScheme:isFlatScheme] 124 | 125 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/Chameleon_.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChameleonInternal.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "ChameleonConstants.h" 13 | #import "ChameleonEnums.h" 14 | #import "ChameleonMacros.h" 15 | 16 | #import "NSArray+Chameleon.h" 17 | #import "UIColor+Chameleon.h" 18 | #import "UINavigationController+Chameleon.h" 19 | #import "UIViewController+Chameleon.h" 20 | 21 | @interface Chameleon : NSObject 22 | 23 | #pragma mark - Global Theming 24 | 25 | /** 26 | * Set a global theme using a primary color and the specified content style. 27 | * 28 | * @param primaryColor The primary color to theme all controllers with. 29 | * @param contentStyle The contentStyle. 30 | * 31 | * @note By default the secondary color will be a darker shade of the specified primary color. 32 | * 33 | * @since 2.0 34 | */ 35 | + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor 36 | withContentStyle:(UIContentStyle)contentStyle; 37 | 38 | /** 39 | * Set a global theme using a primary color, secondary color, and the specified content style. 40 | * 41 | * @param primaryColor The primary color to theme all controllers with. 42 | * @param secondaryColor The secondary color to theme all controllers with. 43 | * @param contentStyle The contentStyle. 44 | * 45 | * @since 2.0 46 | */ 47 | + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor 48 | withSecondaryColor:(UIColor *)secondaryColor 49 | andContentStyle:(UIContentStyle)contentStyle; 50 | 51 | /** 52 | * Set a global theme using a primary color, secondary color, font name, and the specified content style. 53 | * 54 | * @param primaryColor The primary color to theme all controllers with. 55 | * @param secondaryColor The secondary color to theme all controllers with. 56 | * @param fontName The default font for all text-based UI elements. 57 | * @param contentStyle The contentStyle. 58 | * 59 | * @since 2.0 60 | */ 61 | + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor 62 | withSecondaryColor:(UIColor *)secondaryColor 63 | usingFontName:(NSString *)fontName 64 | andContentStyle:(UIContentStyle)contentStyle; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/NSArray+Chameleon.h: -------------------------------------------------------------------------------- 1 | 2 | // NSArray+Chameleon.h 3 | 4 | /* 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2014-2015 Vicc Alexander. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | #import 31 | #import 32 | 33 | #pragma mark - Enums 34 | 35 | /** 36 | * Color schemes with which to select colors using a specified color. 37 | * 38 | * @since 1.0 39 | */ 40 | typedef NS_ENUM(NSInteger, ColorScheme){ 41 | /** 42 | * 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. 43 | * 44 | * @since 1.0 45 | */ 46 | ColorSchemeAnalogous, 47 | /** 48 | * 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. 49 | * 50 | * @since 1.0 51 | */ 52 | ColorSchemeTriadic, 53 | /** 54 | * 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. 55 | * 56 | * @since 1.0 57 | */ 58 | ColorSchemeComplementary 59 | }; 60 | 61 | @interface NSArray (Chameleon) 62 | 63 | #pragma mark - Generating Color Schemes 64 | 65 | /** 66 | * Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. 67 | * 68 | * @param colorScheme The color scheme with which to select colors using a specified color. 69 | * @param color The specified color which the color scheme is built around. 70 | * @param isFlatScheme Pass YES to return flat color objects. 71 | * 72 | * @return An array of 5 color objects in the HSB colorspace. 73 | * 74 | * @since 2.0 75 | */ 76 | + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme 77 | usingColor:(UIColor *)color 78 | withFlatScheme:(BOOL)isFlatScheme; 79 | 80 | /** 81 | * Generates and creates an array of 5 color objects in the HSB colorspace that appear most often in a specified image. 82 | * 83 | * @param image The specified image which the color scheme is built around. 84 | * @param isFlatScheme Pass YES to return flat color objects. 85 | * 86 | * @return An array of 5 color objects in the HSB colorspace. 87 | * 88 | * @since 2.0 89 | */ 90 | + (NSArray *)arrayOfColorsFromImage:(UIImage *)image 91 | withFlatScheme:(BOOL)isFlatScheme; 92 | 93 | #pragma mark - Deprecated Methods 94 | 95 | /** 96 | * Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. 97 | * 98 | * @param colorScheme The color scheme with which to select colors using a specified color. 99 | * 100 | * @param color The specified color which the color scheme is built around. 101 | * 102 | * @param isFlatScheme Pass YES to return flat color objects. 103 | * 104 | * @return An array of 5 color objects in the HSB colorspace. 105 | * 106 | * @since 1.1.2 107 | */ 108 | + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme 109 | with:(UIColor *)color 110 | flatScheme:(BOOL)isFlatScheme __attribute((deprecated(" Use -arrayOfColorsWithColorScheme:usingColor:withFlatScheme: instead (First deprecated in Chameleon 2.0)."))); 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/NSArray+Chameleon.m: -------------------------------------------------------------------------------- 1 | 2 | // NSArray+Chameleon.m 3 | 4 | /* 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2014-2015 Vicc Alexander. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | #import "NSArray+Chameleon.h" 31 | #import "ChameleonMacros.h" 32 | #import "UIColor+ChameleonPrivate.h" 33 | #import "UIImage+ChameleonPrivate.h" 34 | 35 | @interface ChameleonCountedColor : NSObject 36 | 37 | @property (assign) NSUInteger count; 38 | @property (strong) UIColor *color; 39 | 40 | - (id)initWithColor:(UIColor *)color count:(NSUInteger)count; 41 | 42 | @end 43 | 44 | @implementation NSArray (Chameleon) 45 | 46 | #pragma mark - Deprecated 2.0 47 | 48 | + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme { 49 | 50 | //Extract HSB values from input color 51 | CGFloat h, s, b, a; 52 | [color getHue:&h saturation:&s brightness:&b alpha:&a]; 53 | 54 | //Multiply our values by the max value to convert 55 | h *= 360; 56 | s *= 100; 57 | b *= 100; 58 | 59 | //Choose Between Schemes 60 | switch (colorScheme) { 61 | case ColorSchemeAnalogous: 62 | return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; 63 | case ColorSchemeComplementary: 64 | return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; 65 | case ColorSchemeTriadic: 66 | return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; 67 | default: 68 | NSAssert(0, @"Oops! Unrecognized color scheme provided as random color."); 69 | } 70 | } 71 | 72 | #pragma mark - Chameleon - Public Color Scheme Methods 73 | 74 | + (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme usingColor:(UIColor *)color withFlatScheme:(BOOL)isFlatScheme { 75 | 76 | //Extract HSB values from input color 77 | CGFloat h, s, b, a; 78 | [color getHue:&h saturation:&s brightness:&b alpha:&a]; 79 | 80 | //Multiply our values by the max value to convert 81 | h *= 360; 82 | s *= 100; 83 | b *= 100; 84 | 85 | //Choose Between Schemes 86 | switch (colorScheme) { 87 | case ColorSchemeAnalogous: 88 | if (isFlatScheme) return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; 89 | else return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; 90 | case ColorSchemeComplementary: 91 | if (isFlatScheme) return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; 92 | else return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; 93 | case ColorSchemeTriadic: 94 | if (isFlatScheme) return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; 95 | else return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; 96 | default: 97 | NSAssert(0, @"Oops! Unrecognized color scheme provided as random color."); 98 | } 99 | } 100 | 101 | + (NSArray *)arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)isFlatScheme { 102 | 103 | //Quick return in case we don't have an image 104 | if (!image) { 105 | 106 | //Make sure we return some colors to prevent exception 107 | NSMutableArray *emptyColors = [NSMutableArray array]; 108 | while (emptyColors.count < 5) { 109 | [emptyColors addObject:[UIColor whiteColor]]; 110 | } 111 | 112 | return emptyColors; 113 | } 114 | 115 | //Scale image 116 | UIImage *scaledImage = [UIImage imageWithImage:image scaledToSize:CGSizeMake(image.size.width/8, image.size.height/8)]; 117 | NSMutableArray *finalColors = [NSMutableArray array]; 118 | 119 | //Find colors in image ********************************* 120 | 121 | //Get dimensions of image in pixels 122 | size_t width = CGImageGetWidth(scaledImage.CGImage); 123 | size_t height = CGImageGetHeight(scaledImage.CGImage); 124 | 125 | //Initialize a counted set with the correct capacity 126 | NSCountedSet *imageColors = [[NSCountedSet alloc] initWithCapacity:(width * height)]; 127 | 128 | //Loop through each column 129 | for (NSUInteger x = 0; x < width; x++) { 130 | 131 | //Loop through each row 132 | for (NSUInteger y = 0; y < height; y++) { 133 | 134 | //Get color at a specific point 135 | UIColor *color = [UIColor colorFromImage:scaledImage atPoint:CGPointMake(x, y)]; 136 | 137 | //Add color to our list of all pixel colors 138 | [imageColors addObject:color]; 139 | } 140 | } 141 | 142 | //Setup up an enumerator object 143 | NSEnumerator *enumerator = [imageColors objectEnumerator]; 144 | UIColor *currentColor; 145 | NSMutableArray *sortedColors = [NSMutableArray arrayWithCapacity:imageColors.count]; 146 | NSMutableArray *resultColors = [NSMutableArray array]; 147 | 148 | //Enumerate through each object once 149 | while ((currentColor = [enumerator nextObject]) != nil) { 150 | 151 | //Set a minimum allowed saturation 152 | currentColor = [currentColor colorWithMinimumSaturation:0.15f]; 153 | 154 | //Get color count 155 | NSUInteger colorCount = [imageColors countForObject:currentColor]; 156 | 157 | //Add them to our sortedColors array 158 | [sortedColors addObject:[[ChameleonCountedColor alloc] initWithColor:currentColor count:colorCount]]; 159 | } 160 | 161 | //Sort Colors 162 | [sortedColors sortUsingSelector:@selector(compare:)]; 163 | 164 | //Loop through our sorted colors 165 | for (ChameleonCountedColor *countedColor in sortedColors) { 166 | 167 | //Define our current color 168 | currentColor = countedColor.color; 169 | 170 | //Setup a flag to see if we should continue counting 171 | BOOL continueFlag = NO; 172 | 173 | //Loop through our colors 174 | for (UIColor *otherColor in resultColors) { 175 | 176 | //If our current color differs from our last, break the loop 177 | if (![currentColor isDistinct:otherColor]) { 178 | continueFlag = YES; 179 | break; 180 | } 181 | } 182 | 183 | //Continue 184 | if (continueFlag) { 185 | continue; 186 | } 187 | 188 | //If we can still add more colors, do so 189 | if (resultColors.count < 5) { 190 | 191 | //Check if we should flatten our color 192 | if (isFlatScheme) { 193 | [resultColors addObject:[currentColor flatten]]; 194 | } else { 195 | [resultColors addObject:currentColor]; 196 | } 197 | 198 | } else { 199 | break; 200 | } 201 | 202 | } 203 | 204 | //Get colors from image 205 | [finalColors addObjectsFromArray:[NSArray arrayWithArray:resultColors]]; 206 | 207 | // ***************************************************** 208 | 209 | //Make sure we add white colors in case we're missing colors 210 | while (finalColors.count < 5) { 211 | [finalColors addObject:[UIColor whiteColor]]; 212 | } 213 | 214 | //Return array of colors 215 | return [NSArray arrayWithArray:finalColors]; 216 | } 217 | 218 | - (NSArray *)findColorsOfImage:(UIImage *)image imageColors:(NSCountedSet * __autoreleasing *)colors { 219 | 220 | //Get dimensions of image in pixels 221 | size_t width = CGImageGetWidth(image.CGImage); 222 | size_t height = CGImageGetHeight(image.CGImage); 223 | 224 | //Initialize a counted set with the correct capacity 225 | NSCountedSet *imageColors = [[NSCountedSet alloc] initWithCapacity:(width * height)]; 226 | 227 | //Loop through each column 228 | for (NSUInteger x = 0; x < width; x++) { 229 | 230 | //Loop through each row 231 | for (NSUInteger y = 0; y < height; y++) { 232 | 233 | //Get color at a specific point 234 | UIColor *color = [UIColor colorFromImage:image atPoint:CGPointMake(x, y)]; 235 | 236 | //Add color to our list of all pixel colors 237 | [imageColors addObject:color]; 238 | } 239 | } 240 | 241 | //Assign imageColors to colors 242 | *colors = imageColors; 243 | 244 | //Setup up an enumerator object 245 | NSEnumerator *enumerator = [imageColors objectEnumerator]; 246 | UIColor *currentColor; 247 | NSMutableArray *sortedColors = [NSMutableArray arrayWithCapacity:imageColors.count]; 248 | NSMutableArray *resultColors = [NSMutableArray array]; 249 | 250 | //Enumerate through each object once 251 | while ((currentColor = [enumerator nextObject]) != nil) { 252 | 253 | //Set a minimum allowed saturation 254 | currentColor = [currentColor colorWithMinimumSaturation:0.15f]; 255 | 256 | //Get color count 257 | NSUInteger colorCount = [imageColors countForObject:currentColor]; 258 | 259 | //Add them to our sortedColors array 260 | [sortedColors addObject:[[ChameleonCountedColor alloc] initWithColor:currentColor count:colorCount]]; 261 | } 262 | 263 | //Sort Colors 264 | [sortedColors sortUsingSelector:@selector(compare:)]; 265 | 266 | //Loop through our sorted colors 267 | for (ChameleonCountedColor *countedColor in sortedColors) { 268 | 269 | //Define our current color 270 | currentColor = countedColor.color; 271 | 272 | //Setup a flag to see if we should continue counting 273 | BOOL continueFlag = NO; 274 | 275 | //Loop through our colors 276 | for (UIColor *c in resultColors) { 277 | 278 | //If our current color differs from our last, break the loop 279 | if (![currentColor isDistinct:c]) { 280 | continueFlag = YES; 281 | break; 282 | } 283 | } 284 | 285 | //Continue 286 | if (continueFlag) { 287 | continue; 288 | } 289 | 290 | //If we can still add more colors, do so 291 | if (resultColors.count < self.count) { 292 | 293 | [resultColors addObject:currentColor]; 294 | 295 | } else { 296 | break; 297 | } 298 | 299 | } 300 | 301 | //Return our colors 302 | return [NSArray arrayWithArray:resultColors]; 303 | } 304 | 305 | 306 | #pragma mark - Chameleon - Internal Color Scheme Methods 307 | 308 | //Creates an array with 2 analagous colors on each side of the predefined color 309 | + (NSArray *)analogousColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { 310 | 311 | UIColor *firstColor = [UIColor colorWithHue:([[self class] add:-32 to:h])/360 312 | saturation:(s+5)/100 313 | brightness:(b+5)/100 314 | alpha:1.0]; 315 | 316 | UIColor *secondColor = [UIColor colorWithHue:[[self class] add:-16 to:h]/360 317 | saturation:(s+5)/100 318 | brightness:(b+9)/100 319 | alpha:1.0]; 320 | 321 | UIColor *thirdColor = [UIColor colorWithHue:h/360 322 | saturation:s/100 323 | brightness:b/100 324 | alpha:1.0]; 325 | 326 | UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:16 to:h]/360 327 | saturation:(s+5)/100 328 | brightness:(b+9)/100 329 | alpha:1.0]; 330 | 331 | UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:32 to:h]/360 332 | saturation:(s+5)/100 333 | brightness:(b+5)/100 334 | alpha:1.0]; 335 | 336 | if (isFlat) { 337 | 338 | //Flatten colors 339 | firstColor = [firstColor flatten]; 340 | secondColor = [secondColor flatten]; 341 | thirdColor = [thirdColor flatten]; 342 | fourthColor = [fourthColor flatten]; 343 | fifthColor = [fifthColor flatten]; 344 | 345 | //Make sure returned colors are unique 346 | 347 | //Inner Colors 348 | if ([secondColor isEqual:thirdColor]) { 349 | 350 | secondColor = [[UIColor colorWithHue:[[self class] add:-48 to:h]/360 351 | saturation:(s+5)/100 352 | brightness:(b+9)/100 353 | alpha:1.0] flatten]; 354 | } 355 | 356 | if ([thirdColor isEqual:fourthColor]) { 357 | 358 | fourthColor = [[UIColor colorWithHue:[[self class] add:32 to:h]/360 359 | saturation:(s+5)/100 360 | brightness:(b+9)/100 361 | alpha:1.0] flatten]; 362 | } 363 | 364 | //Outer Colors 365 | 366 | if ([firstColor isEqual:secondColor]) { 367 | 368 | firstColor = [[UIColor colorWithHue:[[self class] add:-64 to:h]/360 369 | saturation:(s+5)/100 370 | brightness:(b+9)/100 371 | alpha:1.0] flatten]; 372 | } 373 | 374 | if ([firstColor isEqual:thirdColor]) { 375 | 376 | firstColor = [[UIColor colorWithHue:[[self class] add:-96 to:h]/360 377 | saturation:(s+5)/100 378 | brightness:(b+9)/100 379 | alpha:1.0] darkenByPercentage:0.25]; 380 | } 381 | 382 | if ([fourthColor isEqual:fifthColor]) { 383 | fifthColor = [[UIColor colorWithHue:[[self class] add:64 to:h]/360 384 | saturation:(s+5)/100 385 | brightness:(b+9)/100 386 | alpha:1.0] flatten]; 387 | } 388 | 389 | if ([thirdColor isEqual:fifthColor]) { 390 | fifthColor = [[UIColor colorWithHue:[[self class] add:96 to:h]/360 391 | saturation:(s+5)/100 392 | brightness:(b+9)/100 393 | alpha:1.0] flatten]; 394 | } 395 | 396 | } 397 | 398 | return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; 399 | } 400 | 401 | // Creates an array of 5 colors, both 90 degrees and 180 degrees away from the predefined colors on both sides 402 | + (NSArray *)complementaryColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { 403 | 404 | UIColor *firstColor = [UIColor colorWithHue:h/360 405 | saturation:(s+5)/100 406 | brightness:(b-30)/100 407 | alpha:1.0]; 408 | 409 | UIColor *secondColor = [UIColor colorWithHue:h/360 410 | saturation:(s-10)/100 411 | brightness:(b+9)/100 412 | alpha:1.0]; 413 | 414 | UIColor *thirdColor = [UIColor colorWithHue:h/360 415 | saturation:s/100 416 | brightness:b/100 417 | alpha:1.0]; 418 | 419 | UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:180 to:h]/360 420 | saturation:s/100 421 | brightness:b/100 422 | alpha:1.0]; 423 | 424 | UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:180 to:h]/360 425 | saturation:(s+20)/100 426 | brightness:(b-30)/100 427 | alpha:1.0]; 428 | 429 | 430 | if (isFlat) { 431 | 432 | //Flatten colors 433 | firstColor = [firstColor flatten]; 434 | secondColor = [secondColor flatten]; 435 | thirdColor = [thirdColor flatten]; 436 | fourthColor = [fourthColor flatten]; 437 | fifthColor = [fifthColor flatten]; 438 | 439 | //Make sure returned colors are unique 440 | 441 | //Inner Colors 442 | if ([secondColor isEqual:thirdColor]) { 443 | secondColor = [[secondColor darkenByPercentage:0.25] flatten]; 444 | } 445 | 446 | if ([thirdColor isEqual:fourthColor]) { 447 | fourthColor = [[fourthColor darkenByPercentage:0.25] flatten]; 448 | } 449 | 450 | if ([firstColor isEqual:thirdColor]) { 451 | firstColor = [[firstColor darkenByPercentage:0.25] flatten]; 452 | } 453 | 454 | if ([fifthColor isEqual:thirdColor]) { 455 | fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; 456 | } 457 | 458 | //Outer Colors 459 | 460 | if ([firstColor isEqual:secondColor]) { 461 | firstColor = [[firstColor darkenByPercentage:0.25] flatten]; 462 | } 463 | 464 | 465 | if ([fourthColor isEqual:fifthColor]) { 466 | fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; 467 | } 468 | 469 | } 470 | 471 | return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; 472 | 473 | } 474 | 475 | // Creates an array of 5 colors, both 120 degrees and 240 degrees away from the predefined colors on both sides 476 | + (NSArray *)triadicColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { 477 | 478 | UIColor *firstColor = [UIColor colorWithHue:[[self class] add:120 to:h]/360 479 | saturation:(7*s/6)/100 480 | brightness:(b-5)/100 481 | alpha:1.0]; 482 | 483 | UIColor *secondColor = [UIColor colorWithHue:[[self class] add:120 to:h]/360 484 | saturation:s/100 485 | brightness:(b+9)/100 486 | alpha:1.0]; 487 | 488 | UIColor *thirdColor = [UIColor colorWithHue:h/360 489 | saturation:s/100 490 | brightness:b/100 491 | alpha:1.0]; 492 | 493 | UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:240 to:h]/360 494 | saturation:(7*s/6)/100 495 | brightness:(b-5)/100 496 | alpha:1.0]; 497 | 498 | UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:240 to:h]/360 499 | saturation:s/100 500 | brightness:(b-30)/100 501 | alpha:1.0]; 502 | 503 | if (isFlat) { 504 | 505 | //Flatten colors 506 | firstColor = [firstColor flatten]; 507 | secondColor = [secondColor flatten]; 508 | thirdColor = [thirdColor flatten]; 509 | fourthColor = [fourthColor flatten]; 510 | fifthColor = [fifthColor flatten]; 511 | 512 | //Make sure returned colors are unique 513 | 514 | //Inner Colors 515 | if ([secondColor isEqual:thirdColor]) { 516 | secondColor = [[secondColor darkenByPercentage:0.25] flatten]; 517 | } 518 | 519 | if ([thirdColor isEqual:fourthColor]) { 520 | fourthColor = [[fourthColor darkenByPercentage:0.25] flatten]; 521 | } 522 | 523 | if ([firstColor isEqual:thirdColor]) { 524 | firstColor = [[firstColor darkenByPercentage:0.25] flatten]; 525 | } 526 | 527 | if ([fifthColor isEqual:thirdColor]) { 528 | fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; 529 | } 530 | 531 | //Outer Colors 532 | 533 | if ([firstColor isEqual:secondColor]) { 534 | firstColor = [[firstColor darkenByPercentage:0.25] flatten]; 535 | } 536 | 537 | 538 | if ([fourthColor isEqual:fifthColor]) { 539 | fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; 540 | } 541 | 542 | } 543 | 544 | return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; 545 | } 546 | 547 | #pragma mark - Helper Methods for Color Schemes 548 | 549 | + (float)add:(float)newValue to:(float)currentValue { 550 | 551 | currentValue += newValue; 552 | 553 | //Check if currentValue exceeds 360 degrees 554 | if (currentValue > 360) { 555 | float offset = currentValue - 360; 556 | return offset; 557 | } 558 | 559 | else if (currentValue < 0) { 560 | return -1 * currentValue; 561 | } 562 | 563 | else { 564 | return currentValue; 565 | } 566 | } 567 | 568 | + (UIColor *)colorWithFlatVersionOf:(UIColor *)color { 569 | 570 | //Create CGFloats to hold our color values 571 | CGFloat L, A, B, alpha; 572 | 573 | //Get LAB values for our color 574 | [color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha]; 575 | 576 | //Find the nearest flat color 577 | return [self nearestFlatColorForL:L A:A B:B alpha:1.0]; 578 | } 579 | 580 | //Array of all our colors 581 | + (NSArray *)flatColors { 582 | 583 | 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]; 584 | } 585 | 586 | //Calculate the total sum of differences - Euclidian distance 587 | //Chameleon is now using the CIEDE2000 formula to calculate distances between 2 colors. 588 | //More info: http://en.wikipedia.org/wiki/Color_difference 589 | + (float)totalSumOfDifferencesFroml1:(CGFloat)L1 l2:(CGFloat)L2 a1:(CGFloat)A1 590 | a2:(CGFloat)A2 b1:(CGFloat)B1 b2:(CGFloat)B2 { 591 | 592 | //Get C Values in LCH from LAB Values 593 | CGFloat C1 = sqrt(pow(A1, 2) + pow(B1, 2)); 594 | CGFloat C2 = sqrt(pow(A2, 2) + pow(B2, 2)); 595 | 596 | //CIE Weights 597 | CGFloat KL = 1; 598 | CGFloat KC = 1; 599 | CGFloat KH = 1; 600 | 601 | //Variables specifically set for CIE:2000 602 | CGFloat DeltaPrimeL = L2 - L1; 603 | CGFloat MeanL = ((L1 + L2) / 2); 604 | CGFloat MeanC = ((C1 + C2) / 2); 605 | CGFloat A1Prime = A1 + A1 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); 606 | CGFloat A2Prime = A2 + A2 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); 607 | CGFloat C1Prime = sqrt(pow(A1Prime, 2) + pow(B1, 2)); 608 | CGFloat C2Prime = sqrt(pow(A2Prime, 2) + pow(B2, 2)); 609 | CGFloat DeltaPrimeC = C1Prime - C2Prime; 610 | CGFloat DeltaC = C1 - C2; 611 | CGFloat MeanCPrime = (C1Prime + C2Prime) / 2; 612 | CGFloat H1Prime = fmodf(atan2(B1, A1Prime), (360.0 * M_PI/180)); 613 | CGFloat H2Prime = fmodf(atan2(B2, A2Prime), (360.0 * M_PI/180)); 614 | 615 | //Run everything through our △H' Function 616 | CGFloat hDeltaPrime = 0; 617 | if (fabs(H1Prime - H2Prime) <= (180.0 * M_PI/180)) { 618 | 619 | hDeltaPrime = H2Prime - H1Prime; 620 | 621 | } else if (H2Prime <= H1Prime) { 622 | 623 | hDeltaPrime = (H2Prime - H1Prime) + ((360.0 * M_PI/180)); 624 | 625 | } else { 626 | 627 | hDeltaPrime = (H2Prime - H1Prime) - ((360.0 * M_PI/180)); 628 | } 629 | 630 | CGFloat deltaHPrime = 2 * (sqrt(C1Prime*C2Prime)) * sin(hDeltaPrime/2); 631 | 632 | //Get Mean H' Value 633 | CGFloat MeanHPrime = 0; 634 | if (fabs(H1Prime-H2Prime) > (180.0 * M_PI/180)) { 635 | 636 | MeanHPrime = (H1Prime + H2Prime + (360.0 * M_PI/180)) / 2; 637 | 638 | } else { 639 | 640 | MeanHPrime = (H1Prime + H2Prime) / 2; 641 | } 642 | 643 | 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)); 644 | 645 | CGFloat SL = 1 + (0.015 * pow((MeanL - 50), 2))/sqrt(20 + pow((MeanL - 50), 2)); 646 | CGFloat SC = 1 + 0.045 * MeanCPrime; 647 | CGFloat SH = 1 + 0.015 * MeanCPrime * T; 648 | 649 | 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))); 650 | 651 | 652 | //Get total difference 653 | 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))); 654 | 655 | return TotalDifference; 656 | } 657 | 658 | + (UIColor *)nearestFlatColorForL:(CGFloat)l1 A:(CGFloat)a1 B:(CGFloat)b1 alpha:(CGFloat)alpha{ 659 | 660 | //Keep track of our index 661 | int index = 0; 662 | 663 | //Start with a random big number to make sure the first comparison gets saved. 664 | float smallestDistance = 1000000; 665 | float previousDistance = 1000000; 666 | float currentDistance; 667 | 668 | //Our values 669 | CGFloat l2, a2, b2; 670 | 671 | //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 672 | for (int i=0; i<[[self flatColors] count]; i++ ) { 673 | 674 | //Check that index is not zero 675 | if (i!=0 ) { 676 | //Extract LAB values from colors in array and store it as the previous index 677 | [[self flatColors][i - 1] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; 678 | 679 | previousDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 680 | a1:a1 a2:a2 681 | b1:b1 b2:b2]; 682 | } 683 | 684 | //Extract LAB values from colors in array and store it as the current index 685 | [[self flatColors][i] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; 686 | 687 | currentDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 688 | a1:a1 a2:a2 689 | b1:b1 b2:b2]; 690 | 691 | //We're only interested in the smallest difference 692 | if (currentDistance < previousDistance) { 693 | if (currentDistance < smallestDistance) { 694 | smallestDistance = currentDistance; 695 | index = i; 696 | } 697 | } 698 | } 699 | 700 | 701 | //Collect the RGB Values of the color where the smallest difference was found 702 | CGFloat red, green, blue; 703 | [[self flatColors][index] getRed:&red green:&green blue:&blue alpha:nil]; 704 | 705 | //Return the closest flat color 706 | return rgba(red*255, green*255, blue*255, alpha); 707 | } 708 | 709 | @end 710 | 711 | @implementation ChameleonCountedColor 712 | 713 | - (id)initWithColor:(UIColor *)color count:(NSUInteger)count { 714 | 715 | if ((self = [super init])) { 716 | self.color = color; 717 | self.count = count; 718 | } 719 | 720 | return self; 721 | } 722 | 723 | - (NSComparisonResult)compare:(ChameleonCountedColor *)object { 724 | 725 | if ([object isKindOfClass:[ChameleonCountedColor class]]) { 726 | if (self.count < object.count) 727 | return NSOrderedDescending; 728 | else if (self.count == object.count) 729 | return NSOrderedSame; 730 | } 731 | 732 | return NSOrderedAscending; 733 | } 734 | 735 | 736 | @end 737 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIAppearance+Swift.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAppearance+Swift.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (UIViewAppearance_Swift) 12 | 13 | // @param containers An array of Class < UIAppearanceContainer > 14 | // http://stackoverflow.com/a/28765193 15 | + (instancetype)appearanceWhenContainedWithin:(NSArray *)containers; 16 | 17 | @end -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIAppearance+Swift.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIAppearance+Swift.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 11/26/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UIAppearance+Swift.h" 10 | 11 | @implementation UIView (UIViewAppearance_Swift) 12 | 13 | + (instancetype)appearanceWhenContainedWithin: (NSArray *)containers { 14 | 15 | NSUInteger count = containers.count; 16 | NSAssert(count <= 10, @"The count of containers greater than 10 is not supported."); 17 | 18 | return [self appearanceWhenContainedIn: 19 | count > 0 ? containers[0] : nil, 20 | count > 1 ? containers[1] : nil, 21 | count > 2 ? containers[2] : nil, 22 | count > 3 ? containers[3] : nil, 23 | count > 4 ? containers[4] : nil, 24 | count > 5 ? containers[5] : nil, 25 | count > 6 ? containers[6] : nil, 26 | count > 7 ? containers[7] : nil, 27 | count > 8 ? containers[8] : nil, 28 | count > 9 ? containers[9] : nil, 29 | nil]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIButton+Chameleon.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+Chameleon.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 9/20/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIButton (Chameleon) 12 | 13 | - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIButton+Chameleon.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+Chameleon.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 9/20/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UIButton+Chameleon.h" 10 | 11 | @implementation UIButton (Chameleon) 12 | 13 | #pragma GCC diagnostic push 14 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 15 | 16 | - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR { 17 | 18 | self.font = [UIFont fontWithName:name size:self.font.pointSize]; 19 | } 20 | 21 | #pragma GCC diagnostic pop 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIColor+Chameleon.h: -------------------------------------------------------------------------------- 1 | 2 | // UIColor+Chameleon.h 3 | 4 | /* 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2014-2015 Vicc Alexander. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | #import 31 | #import 32 | 33 | NS_ASSUME_NONNULL_BEGIN 34 | 35 | #pragma mark - Enums 36 | 37 | /** 38 | * Defines the gradient style and direction of the gradient color. 39 | * 40 | * @since 1.0 41 | */ 42 | typedef NS_ENUM (NSUInteger, UIGradientStyle) { 43 | /** 44 | * 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. 45 | * 46 | * @since 1.0 47 | */ 48 | UIGradientStyleLeftToRight, 49 | /** 50 | * 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. 51 | * 52 | * @since 1.0 53 | */ 54 | UIGradientStyleRadial, 55 | /** 56 | * 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. 57 | * 58 | * @since 1.0 59 | */ 60 | UIGradientStyleTopToBottom, 61 | UIGradientStyleDiagonal 62 | }; 63 | 64 | /** 65 | * Defines the shade of a any flat color. 66 | * 67 | * @since 1.0 68 | */ 69 | typedef NS_ENUM (NSInteger, UIShadeStyle) { 70 | /** 71 | * Returns the light shade version of a flat color. 72 | * 73 | * @since 1.0 74 | */ 75 | UIShadeStyleLight, 76 | /** 77 | * Returns the dark shade version of a flat color. 78 | * 79 | * @since 1.0 80 | */ 81 | UIShadeStyleDark 82 | }; 83 | 84 | 85 | @interface UIColor (Chameleon) 86 | 87 | #pragma mark - Instance Variables 88 | 89 | /** 90 | * Stores an object's UIColor image if the UIColor was created using colorWithPatternImage. 91 | * 92 | * @since 1.0 93 | */ 94 | 95 | @property (nonatomic, strong) UIImage *gradientImage; 96 | 97 | #pragma mark - Quick Shorthand Macros 98 | 99 | // Quick & Easy Shorthand for RGB x HSB Colors 100 | // The reason we don't import our Macro file is to prevent naming conflicts. 101 | #define rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a] 102 | #define rgb(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0] 103 | #define hsba(h,s,b,a) [UIColor colorWithHue:h/360.0f saturation:s/100.0f brightness:b/100.0f alpha:a] 104 | #define hsb(h,s,b) [UIColor colorWithHue:h/360.0f saturation:s/100.0f brightness:b/100.0f alpha:1.0] 105 | 106 | #pragma mark - Light Shades 107 | 108 | #if UIKIT_DEFINE_AS_PROPERTIES 109 | /** 110 | * Returns a flat color object whose HSB values are 0.0, 0.0, 0.17 and whose alpha value is 1.0. 111 | * 112 | * @return A flat UIColor object in the HSB colorspace. 113 | */ 114 | @property(class, nonatomic, readonly) UIColor *flatBlackColor; 115 | 116 | /** 117 | * Returns a flat color object whose HSB values are 0.62, 0.50, 0.63 and whose alpha value is 1.0. 118 | * 119 | * @return A flat UIColor object in the HSB colorspace. 120 | */ 121 | @property(class, nonatomic, readonly) UIColor *flatBlueColor; 122 | 123 | /** 124 | * Returns a flat color object whose HSB values are 0.07, 0.45, 0.37 and whose alpha value is 1.0. 125 | * 126 | * @return A flat UIColor object in the HSB colorspace. 127 | */ 128 | @property(class, nonatomic, readonly) UIColor *flatBrownColor; 129 | 130 | /** 131 | * Returns a flat color object whose HSB values are 0.07, 0.31, 0.64 and whose alpha value is 1.0. 132 | * 133 | * @return A flat UIColor object in the HSB colorspace. 134 | */ 135 | @property(class, nonatomic, readonly) UIColor *flatCoffeeColor; 136 | 137 | /** 138 | * Returns a flat color object whose HSB values are 0.38, 0.45, 0.37 and whose alpha value is 1.0. 139 | * 140 | * @return A flat UIColor object in the HSB colorspace. 141 | */ 142 | @property(class, nonatomic, readonly) UIColor *flatForestGreenColor; 143 | 144 | /** 145 | * Returns a flat color object whose HSB values are 0.51, 0.10, 0.65 and whose alpha value is 1.0. 146 | * 147 | * @return A flat UIColor object in the HSB colorspace. 148 | */ 149 | @property(class, nonatomic, readonly) UIColor *flatGrayColor; 150 | 151 | /** 152 | * Returns a flat color object whose HSB values are 0.40, 0.77, 0.80 and whose alpha value is 1.0. 153 | * 154 | * @return A flat UIColor object in the HSB colorspace. 155 | */ 156 | @property(class, nonatomic, readonly) UIColor *flatGreenColor; 157 | 158 | /** 159 | * Returns a flat color object whose HSB values are 0.21, 0.70, 0.78 and whose alpha value is 1.0. 160 | * 161 | * @return A flat UIColor object in the HSB colorspace. 162 | */ 163 | @property(class, nonatomic, readonly) UIColor *flatLimeColor; 164 | 165 | /** 166 | * Returns a flat color object whose HSB values are 0.79, 0.51, 0.71 and whose alpha value is 1.0. 167 | * 168 | * @return A flat UIColor object in the HSB colorspace. 169 | */ 170 | @property(class, nonatomic, readonly) UIColor *flatMagentaColor; 171 | 172 | /** 173 | * Returns a flat color object whose HSB values are 0.01, 0.65, 0.47 and whose alpha value is 1.0. 174 | * 175 | * @return A flat UIColor object in the HSB colorspace. 176 | */ 177 | @property(class, nonatomic, readonly) UIColor *flatMaroonColor; 178 | 179 | /** 180 | * Returns a flat color object whose HSB values are 0.47, 0.86, 0.74 and whose alpha value is 1.0. 181 | * 182 | * @return A flat UIColor object in the HSB colorspace. 183 | */ 184 | @property(class, nonatomic, readonly) UIColor *flatMintColor; 185 | 186 | /** 187 | * Returns a flat color object whose HSB values are 0.58, 0.45, 0.37 and whose alpha value is 1.0. 188 | * 189 | * @return A flat UIColor object in the HSB colorspace. 190 | */ 191 | @property(class, nonatomic, readonly) UIColor *flatNavyBlueColor; 192 | 193 | /** 194 | * Returns a flat color object whose HSB values are 0.08, 0.85, 0.90 and whose alpha value is 1.0. 195 | * 196 | * @return A flat UIColor object in the HSB colorspace. 197 | */ 198 | @property(class, nonatomic, readonly) UIColor *flatOrangeColor; 199 | 200 | /** 201 | * Returns a flat color object whose HSB values are 0.90, 0.49, 0.96 and whose alpha value is 1.0. 202 | * 203 | * @return A flat UIColor object in the HSB colorspace. 204 | */ 205 | @property(class, nonatomic, readonly) UIColor *flatPinkColor; 206 | 207 | /** 208 | * Returns a flat color object whose HSB values are 0.83, 0.45, 0.37 and whose alpha value is 1.0. 209 | * 210 | * @return A flat UIColor object in the HSB colorspace. 211 | */ 212 | @property(class, nonatomic, readonly) UIColor *flatPlumColor; 213 | 214 | /** 215 | * Returns a flat color object whose HSB values are 0.62, 0.24, 0.95 and whose alpha value is 1.0. 216 | * 217 | * @return A flat UIColor object in the HSB colorspace. 218 | */ 219 | @property(class, nonatomic, readonly) UIColor *flatPowderBlueColor; 220 | 221 | /** 222 | * Returns a flat color object whose HSB values are 0.70, 0.52, 0.77 and whose alpha value is 1.0. 223 | * 224 | * @return A flat UIColor object in the HSB colorspace. 225 | */ 226 | @property(class, nonatomic, readonly) UIColor *flatPurpleColor; 227 | 228 | /** 229 | * Returns a flat color object whose HSB values are 0.02, 0.74, 0.91 and whose alpha value is 1.0. 230 | * 231 | * @return A flat UIColor object in the HSB colorspace. 232 | */ 233 | @property(class, nonatomic, readonly) UIColor *flatRedColor; 234 | 235 | /** 236 | * Returns a flat color object whose HSB values are 0.12, 0.25, 0.94 and whose alpha value is 1.0. 237 | * 238 | * @return A flat UIColor object in the HSB colorspace. 239 | */ 240 | @property(class, nonatomic, readonly) UIColor *flatSandColor; 241 | 242 | /** 243 | * Returns a flat color object whose HSB values are 0.57, 0.76, 0.86 and whose alpha value is 1.0. 244 | * 245 | * @return A flat UIColor object in the HSB colorspace. 246 | */ 247 | @property(class, nonatomic, readonly) UIColor *flatSkyBlueColor; 248 | 249 | /** 250 | * Returns a flat color object whose HSB values are 0.54, 0.55, 0.51 and whose alpha value is 1.0. 251 | * 252 | * @return A flat UIColor object in the HSB colorspace. 253 | */ 254 | @property(class, nonatomic, readonly) UIColor *flatTealColor; 255 | 256 | /** 257 | * Returns a flat color object whose HSB values are 0.99, 0.53, 0.94 and whose alpha value is 1.0. 258 | * 259 | * @return A flat UIColor object in the HSB colorspace. 260 | */ 261 | @property(class, nonatomic, readonly) UIColor *flatWatermelonColor; 262 | 263 | /** 264 | * Returns a flat color object whose HSB values are 0.53, 0.02, 0.95 and whose alpha value is 1.0. 265 | * 266 | * @return A flat UIColor object in the HSB colorspace. 267 | */ 268 | @property(class, nonatomic, readonly) UIColor *flatWhiteColor; 269 | 270 | /** 271 | * Returns a flat color object whose HSB values are 0.13, 0.99, 1.00 and whose alpha value is 1.0. 272 | * 273 | * @return A flat UIColor object in the HSB colorspace. 274 | */ 275 | @property(class, nonatomic, readonly) UIColor *flatYellowColor; 276 | #else 277 | 278 | /** 279 | * Returns a flat color object whose HSB values are 0.0, 0.0, 0.17 and whose alpha value is 1.0. 280 | * 281 | * @return A flat UIColor object in the HSB colorspace. 282 | */ 283 | + (UIColor *)flatBlackColor; 284 | 285 | /** 286 | * Returns a flat color object whose HSB values are 0.62, 0.50, 0.63 and whose alpha value is 1.0. 287 | * 288 | * @return A flat UIColor object in the HSB colorspace. 289 | */ 290 | + (UIColor *)flatBlueColor; 291 | 292 | /** 293 | * Returns a flat color object whose HSB values are 0.07, 0.45, 0.37 and whose alpha value is 1.0. 294 | * 295 | * @return A flat UIColor object in the HSB colorspace. 296 | */ 297 | + (UIColor *)flatBrownColor; 298 | 299 | /** 300 | * Returns a flat color object whose HSB values are 0.07, 0.31, 0.64 and whose alpha value is 1.0. 301 | * 302 | * @return A flat UIColor object in the HSB colorspace. 303 | */ 304 | + (UIColor *)flatCoffeeColor; 305 | 306 | /** 307 | * Returns a flat color object whose HSB values are 0.38, 0.45, 0.37 and whose alpha value is 1.0. 308 | * 309 | * @return A flat UIColor object in the HSB colorspace. 310 | */ 311 | + (UIColor *)flatForestGreenColor; 312 | 313 | /** 314 | * Returns a flat color object whose HSB values are 0.51, 0.10, 0.65 and whose alpha value is 1.0. 315 | * 316 | * @return A flat UIColor object in the HSB colorspace. 317 | */ 318 | + (UIColor *)flatGrayColor; 319 | 320 | /** 321 | * Returns a flat color object whose HSB values are 0.40, 0.77, 0.80 and whose alpha value is 1.0. 322 | * 323 | * @return A flat UIColor object in the HSB colorspace. 324 | */ 325 | + (UIColor *)flatGreenColor; 326 | 327 | /** 328 | * Returns a flat color object whose HSB values are 0.21, 0.70, 0.78 and whose alpha value is 1.0. 329 | * 330 | * @return A flat UIColor object in the HSB colorspace. 331 | */ 332 | + (UIColor *)flatLimeColor; 333 | 334 | /** 335 | * Returns a flat color object whose HSB values are 0.79, 0.51, 0.71 and whose alpha value is 1.0. 336 | * 337 | * @return A flat UIColor object in the HSB colorspace. 338 | */ 339 | + (UIColor *)flatMagentaColor; 340 | 341 | /** 342 | * Returns a flat color object whose HSB values are 0.01, 0.65, 0.47 and whose alpha value is 1.0. 343 | * 344 | * @return A flat UIColor object in the HSB colorspace. 345 | */ 346 | + (UIColor *)flatMaroonColor; 347 | 348 | /** 349 | * Returns a flat color object whose HSB values are 0.47, 0.86, 0.74 and whose alpha value is 1.0. 350 | * 351 | * @return A flat UIColor object in the HSB colorspace. 352 | */ 353 | + (UIColor *)flatMintColor; 354 | 355 | /** 356 | * Returns a flat color object whose HSB values are 0.58, 0.45, 0.37 and whose alpha value is 1.0. 357 | * 358 | * @return A flat UIColor object in the HSB colorspace. 359 | */ 360 | + (UIColor *)flatNavyBlueColor; 361 | 362 | /** 363 | * Returns a flat color object whose HSB values are 0.08, 0.85, 0.90 and whose alpha value is 1.0. 364 | * 365 | * @return A flat UIColor object in the HSB colorspace. 366 | */ 367 | + (UIColor *)flatOrangeColor; 368 | 369 | /** 370 | * Returns a flat color object whose HSB values are 0.90, 0.49, 0.96 and whose alpha value is 1.0. 371 | * 372 | * @return A flat UIColor object in the HSB colorspace. 373 | */ 374 | + (UIColor *)flatPinkColor; 375 | 376 | /** 377 | * Returns a flat color object whose HSB values are 0.83, 0.45, 0.37 and whose alpha value is 1.0. 378 | * 379 | * @return A flat UIColor object in the HSB colorspace. 380 | */ 381 | + (UIColor *)flatPlumColor; 382 | 383 | /** 384 | * Returns a flat color object whose HSB values are 0.62, 0.24, 0.95 and whose alpha value is 1.0. 385 | * 386 | * @return A flat UIColor object in the HSB colorspace. 387 | */ 388 | + (UIColor *)flatPowderBlueColor; 389 | 390 | /** 391 | * Returns a flat color object whose HSB values are 0.70, 0.52, 0.77 and whose alpha value is 1.0. 392 | * 393 | * @return A flat UIColor object in the HSB colorspace. 394 | */ 395 | + (UIColor *)flatPurpleColor; 396 | 397 | /** 398 | * Returns a flat color object whose HSB values are 0.02, 0.74, 0.91 and whose alpha value is 1.0. 399 | * 400 | * @return A flat UIColor object in the HSB colorspace. 401 | */ 402 | + (UIColor *)flatRedColor; 403 | 404 | /** 405 | * Returns a flat color object whose HSB values are 0.12, 0.25, 0.94 and whose alpha value is 1.0. 406 | * 407 | * @return A flat UIColor object in the HSB colorspace. 408 | */ 409 | + (UIColor *)flatSandColor; 410 | 411 | /** 412 | * Returns a flat color object whose HSB values are 0.57, 0.76, 0.86 and whose alpha value is 1.0. 413 | * 414 | * @return A flat UIColor object in the HSB colorspace. 415 | */ 416 | + (UIColor *)flatSkyBlueColor; 417 | 418 | /** 419 | * Returns a flat color object whose HSB values are 0.54, 0.55, 0.51 and whose alpha value is 1.0. 420 | * 421 | * @return A flat UIColor object in the HSB colorspace. 422 | */ 423 | + (UIColor *)flatTealColor; 424 | 425 | /** 426 | * Returns a flat color object whose HSB values are 0.99, 0.53, 0.94 and whose alpha value is 1.0. 427 | * 428 | * @return A flat UIColor object in the HSB colorspace. 429 | */ 430 | + (UIColor *)flatWatermelonColor; 431 | 432 | /** 433 | * Returns a flat color object whose HSB values are 0.53, 0.02, 0.95 and whose alpha value is 1.0. 434 | * 435 | * @return A flat UIColor object in the HSB colorspace. 436 | */ 437 | + (UIColor *)flatWhiteColor; 438 | 439 | /** 440 | * Returns a flat color object whose HSB values are 0.13, 0.99, 1.00 and whose alpha value is 1.0. 441 | * 442 | * @return A flat UIColor object in the HSB colorspace. 443 | */ 444 | + (UIColor *)flatYellowColor; 445 | 446 | #endif 447 | 448 | #pragma mark - Dark Shades 449 | 450 | #if UIKIT_DEFINE_AS_PROPERTIES 451 | /** 452 | * Returns a flat color object whose HSB values are 0.00, 0.00, 0.15 and whose alpha value is 1.0. 453 | * 454 | * @return A flat @c UIColor object in the HSB colorspace. 455 | */ 456 | @property(class, nonatomic, readonly) UIColor *flatBlackDarkColor; 457 | 458 | /** 459 | * Returns a flat color object whose HSB values are 0.62, 0.56, 0.51 and whose alpha value is 1.0. 460 | * 461 | * @return A flat @c UIColor object in the HSB colorspace. 462 | */ 463 | @property(class, nonatomic, readonly) UIColor *flatBlueDarkColor; 464 | 465 | /** 466 | * Returns a flat color object whose HSB values are 0.07, 0.45, 0.31 and whose alpha value is 1.0. 467 | * 468 | * @return A flat @c UIColor object in the HSB colorspace. 469 | */ 470 | @property(class, nonatomic, readonly) UIColor *flatBrownDarkColor; 471 | 472 | /** 473 | * Returns a flat color object whose HSB values are 0.07, 0.34, 0.56 and whose alpha value is 1.0. 474 | * 475 | * @return A flat @c UIColor object in the HSB colorspace. 476 | */ 477 | @property(class, nonatomic, readonly) UIColor *flatCoffeeDarkColor; 478 | 479 | /** 480 | * Returns a flat color object whose HSB values are 0.38, 0.44, 0.31 and whose alpha value is 1.0. 481 | * 482 | * @return A flat @c UIColor object in the HSB colorspace. 483 | */ 484 | @property(class, nonatomic, readonly) UIColor *flatForestGreenDarkColor; 485 | 486 | /** 487 | * Returns a flat color object whose HSB values are 0.51, 0.10, 0.55 and whose alpha value is 1.0. 488 | * 489 | * @return A flat @c UIColor object in the HSB colorspace. 490 | */ 491 | @property(class, nonatomic, readonly) UIColor *flatGrayDarkColor; 492 | 493 | /** 494 | * Returns a flat color object whose HSB values are 0.40, 0.78, 0.68 and whose alpha value is 1.0. 495 | * 496 | * @return A flat @c UIColor object in the HSB colorspace. 497 | */ 498 | @property(class, nonatomic, readonly) UIColor *flatGreenDarkColor; 499 | 500 | /** 501 | * Returns a flat color object whose HSB values are 0.21, 0.81, 0.69 and whose alpha value is 1.0. 502 | * 503 | * @return A flat @c UIColor object in the HSB colorspace. 504 | */ 505 | @property(class, nonatomic, readonly) UIColor *flatLimeDarkColor; 506 | 507 | /** 508 | * Returns a flat color object whose HSB values are 0.78, 0.61, 0.68 and whose alpha value is 1.0. 509 | * 510 | * @return A flat @c UIColor object in the HSB colorspace. 511 | */ 512 | @property(class, nonatomic, readonly) UIColor *flatMagentaDarkColor; 513 | 514 | /** 515 | * Returns a flat color object whose HSB values are 0.01, 0.68, 0.40 and whose alpha value is 1.0. 516 | * 517 | * @return A flat @c UIColor object in the HSB colorspace. 518 | */ 519 | @property(class, nonatomic, readonly) UIColor *flatMaroonDarkColor; 520 | 521 | /** 522 | * Returns a flat color object whose HSB values are 0.47, 0.86, 0.63 and whose alpha value is 1.0. 523 | * 524 | * @return A flat @c UIColor object in the HSB colorspace. 525 | */ 526 | @property(class, nonatomic, readonly) UIColor *flatMintDarkColor; 527 | 528 | /** 529 | * Returns a flat color object whose HSB values are 0.58, 0.45, 0.31 and whose alpha value is 1.0. 530 | * 531 | * @return A flat @c UIColor object in the HSB colorspace. 532 | */ 533 | @property(class, nonatomic, readonly) UIColor *flatNavyBlueDarkColor; 534 | 535 | /** 536 | * Returns a flat color object whose HSB values are 0.07, 1.00, 0.83 and whose alpha value is 1.0. 537 | * 538 | * @return A flat @c UIColor object in the HSB colorspace. 539 | */ 540 | @property(class, nonatomic, readonly) UIColor *flatOrangeDarkColor; 541 | 542 | /** 543 | * Returns a flat color object whose HSB values are 0.91, 0.57, 0.83 and whose alpha value is 1.0. 544 | * 545 | * @return A flat @c UIColor object in the HSB colorspace. 546 | */ 547 | @property(class, nonatomic, readonly) UIColor *flatPinkDarkColor; 548 | 549 | /** 550 | * Returns a flat color object whose HSB values are 0.83, 0.46, 0.31 and whose alpha value is 1.0. 551 | * 552 | * @return A flat @c UIColor object in the HSB colorspace. 553 | */ 554 | @property(class, nonatomic, readonly) UIColor *flatPlumDarkColor; 555 | 556 | /** 557 | * Returns a flat color object whose HSB values are 0.62, 0.28, 0.84 and whose alpha value is 1.0. 558 | * 559 | * @return A flat @c UIColor object in the HSB colorspace. 560 | */ 561 | @property(class, nonatomic, readonly) UIColor *flatPowderBlueDarkColor; 562 | 563 | /** 564 | * Returns a flat color object whose HSB values are 0.70, 0.56, 0.64 and whose alpha value is 1.0. 565 | * 566 | * @return A flat @c UIColor object in the HSB colorspace. 567 | */ 568 | @property(class, nonatomic, readonly) UIColor *flatPurpleDarkColor; 569 | 570 | /** 571 | * Returns a flat color object whose HSB values are 0.02, 0.78, 0.75 and whose alpha value is 1.0. 572 | * 573 | * @return A flat @c UIColor object in the HSB colorspace. 574 | */ 575 | @property(class, nonatomic, readonly) UIColor *flatRedDarkColor; 576 | 577 | /** 578 | * Returns a flat color object whose HSB values are 0.12, 0.30, 0.84 and whose alpha value is 1.0. 579 | * 580 | * @return A flat @c UIColor object in the HSB colorspace. 581 | */ 582 | @property(class, nonatomic, readonly) UIColor *flatSandDarkColor; 583 | 584 | /** 585 | * Returns a flat color object whose HSB values are 0.57, 0.78, 0.73 and whose alpha value is 1.0. 586 | * 587 | * @return A flat @c UIColor object in the HSB colorspace. 588 | */ 589 | @property(class, nonatomic, readonly) UIColor *flatSkyBlueDarkColor; 590 | 591 | /** 592 | * Returns a flat color object whose HSB values are 0.54, 0.54, 0.45 and whose alpha value is 1.0. 593 | * 594 | * @return A flat @c UIColor object in the HSB colorspace. 595 | */ 596 | @property(class, nonatomic, readonly) UIColor *flatTealDarkColor; 597 | 598 | /** 599 | * Returns a flat color object whose HSB values are 0.99, 0.61, 0.85 and whose alpha value is 1.0. 600 | * 601 | * @return A flat @c UIColor object in the HSB colorspace. 602 | */ 603 | @property(class, nonatomic, readonly) UIColor *flatWatermelonDarkColor; 604 | 605 | /** 606 | * Returns a flat color object whose HSB values are 0.57, 0.05, 0.78 and whose alpha value is 1.0. 607 | * 608 | * @return A flat @c UIColor object in the HSB colorspace. 609 | */ 610 | @property(class, nonatomic, readonly) UIColor *flatWhiteDarkColor; 611 | 612 | /** 613 | * Returns a flat color object whose HSB values are 0.11, 1.00, 1.00 and whose alpha value is 1.0. 614 | * 615 | * @return A flat @c UIColor object in the HSB colorspace. 616 | */ 617 | @property(class, nonatomic, readonly) UIColor *flatYellowDarkColor; 618 | #else 619 | 620 | /** 621 | * Returns a flat color object whose HSB values are 0.00, 0.00, 0.15 and whose alpha value is 1.0. 622 | * 623 | * @return A flat @c UIColor object in the HSB colorspace. 624 | */ 625 | + (UIColor *)flatBlackDarkColor; 626 | 627 | /** 628 | * Returns a flat color object whose HSB values are 0.62, 0.56, 0.51 and whose alpha value is 1.0. 629 | * 630 | * @return A flat @c UIColor object in the HSB colorspace. 631 | */ 632 | + (UIColor *)flatBlueDarkColor; 633 | 634 | /** 635 | * Returns a flat color object whose HSB values are 0.07, 0.45, 0.31 and whose alpha value is 1.0. 636 | * 637 | * @return A flat @c UIColor object in the HSB colorspace. 638 | */ 639 | + (UIColor *)flatBrownDarkColor; 640 | 641 | /** 642 | * Returns a flat color object whose HSB values are 0.07, 0.34, 0.56 and whose alpha value is 1.0. 643 | * 644 | * @return A flat @c UIColor object in the HSB colorspace. 645 | */ 646 | + (UIColor *)flatCoffeeDarkColor; 647 | 648 | /** 649 | * Returns a flat color object whose HSB values are 0.38, 0.44, 0.31 and whose alpha value is 1.0. 650 | * 651 | * @return A flat @c UIColor object in the HSB colorspace. 652 | */ 653 | + (UIColor *)flatForestGreenDarkColor; 654 | 655 | /** 656 | * Returns a flat color object whose HSB values are 0.51, 0.10, 0.55 and whose alpha value is 1.0. 657 | * 658 | * @return A flat @c UIColor object in the HSB colorspace. 659 | */ 660 | + (UIColor *)flatGrayDarkColor; 661 | 662 | /** 663 | * Returns a flat color object whose HSB values are 0.40, 0.78, 0.68 and whose alpha value is 1.0. 664 | * 665 | * @return A flat @c UIColor object in the HSB colorspace. 666 | */ 667 | + (UIColor *)flatGreenDarkColor; 668 | 669 | /** 670 | * Returns a flat color object whose HSB values are 0.21, 0.81, 0.69 and whose alpha value is 1.0. 671 | * 672 | * @return A flat @c UIColor object in the HSB colorspace. 673 | */ 674 | + (UIColor *)flatLimeDarkColor; 675 | 676 | /** 677 | * Returns a flat color object whose HSB values are 0.78, 0.61, 0.68 and whose alpha value is 1.0. 678 | * 679 | * @return A flat @c UIColor object in the HSB colorspace. 680 | */ 681 | + (UIColor *)flatMagentaDarkColor; 682 | 683 | /** 684 | * Returns a flat color object whose HSB values are 0.01, 0.68, 0.40 and whose alpha value is 1.0. 685 | * 686 | * @return A flat @c UIColor object in the HSB colorspace. 687 | */ 688 | + (UIColor *)flatMaroonDarkColor; 689 | 690 | /** 691 | * Returns a flat color object whose HSB values are 0.47, 0.86, 0.63 and whose alpha value is 1.0. 692 | * 693 | * @return A flat @c UIColor object in the HSB colorspace. 694 | */ 695 | + (UIColor *)flatMintDarkColor; 696 | 697 | /** 698 | * Returns a flat color object whose HSB values are 0.58, 0.45, 0.31 and whose alpha value is 1.0. 699 | * 700 | * @return A flat @c UIColor object in the HSB colorspace. 701 | */ 702 | + (UIColor *)flatNavyBlueDarkColor; 703 | 704 | /** 705 | * Returns a flat color object whose HSB values are 0.07, 1.00, 0.83 and whose alpha value is 1.0. 706 | * 707 | * @return A flat @c UIColor object in the HSB colorspace. 708 | */ 709 | + (UIColor *)flatOrangeDarkColor; 710 | 711 | /** 712 | * Returns a flat color object whose HSB values are 0.91, 0.57, 0.83 and whose alpha value is 1.0. 713 | * 714 | * @return A flat @c UIColor object in the HSB colorspace. 715 | */ 716 | + (UIColor *)flatPinkDarkColor; 717 | 718 | /** 719 | * Returns a flat color object whose HSB values are 0.83, 0.46, 0.31 and whose alpha value is 1.0. 720 | * 721 | * @return A flat @c UIColor object in the HSB colorspace. 722 | */ 723 | + (UIColor *)flatPlumDarkColor; 724 | 725 | /** 726 | * Returns a flat color object whose HSB values are 0.62, 0.28, 0.84 and whose alpha value is 1.0. 727 | * 728 | * @return A flat @c UIColor object in the HSB colorspace. 729 | */ 730 | + (UIColor *)flatPowderBlueDarkColor; 731 | 732 | /** 733 | * Returns a flat color object whose HSB values are 0.70, 0.56, 0.64 and whose alpha value is 1.0. 734 | * 735 | * @return A flat @c UIColor object in the HSB colorspace. 736 | */ 737 | + (UIColor *)flatPurpleDarkColor; 738 | 739 | /** 740 | * Returns a flat color object whose HSB values are 0.02, 0.78, 0.75 and whose alpha value is 1.0. 741 | * 742 | * @return A flat @c UIColor object in the HSB colorspace. 743 | */ 744 | + (UIColor *)flatRedDarkColor; 745 | 746 | /** 747 | * Returns a flat color object whose HSB values are 0.12, 0.30, 0.84 and whose alpha value is 1.0. 748 | * 749 | * @return A flat @c UIColor object in the HSB colorspace. 750 | */ 751 | + (UIColor *)flatSandDarkColor; 752 | 753 | /** 754 | * Returns a flat color object whose HSB values are 0.57, 0.78, 0.73 and whose alpha value is 1.0. 755 | * 756 | * @return A flat @c UIColor object in the HSB colorspace. 757 | */ 758 | + (UIColor *)flatSkyBlueDarkColor; 759 | 760 | /** 761 | * Returns a flat color object whose HSB values are 0.54, 0.54, 0.45 and whose alpha value is 1.0. 762 | * 763 | * @return A flat @c UIColor object in the HSB colorspace. 764 | */ 765 | + (UIColor *)flatTealDarkColor; 766 | 767 | /** 768 | * Returns a flat color object whose HSB values are 0.99, 0.61, 0.85 and whose alpha value is 1.0. 769 | * 770 | * @return A flat @c UIColor object in the HSB colorspace. 771 | */ 772 | + (UIColor *)flatWatermelonDarkColor; 773 | 774 | /** 775 | * Returns a flat color object whose HSB values are 0.57, 0.05, 0.78 and whose alpha value is 1.0. 776 | * 777 | * @return A flat @c UIColor object in the HSB colorspace. 778 | */ 779 | + (UIColor *)flatWhiteDarkColor; 780 | 781 | /** 782 | * Returns a flat color object whose HSB values are 0.11, 1.00, 1.00 and whose alpha value is 1.0. 783 | * 784 | * @return A flat @c UIColor object in the HSB colorspace. 785 | */ 786 | + (UIColor *)flatYellowDarkColor; 787 | #endif 788 | 789 | #pragma mark - Randomizing Colors 790 | #if UIKIT_DEFINE_AS_PROPERTIES 791 | /** 792 | * Returns a randomly generated flat color object whose alpha value is 1.0. 793 | * 794 | * @return A flat @c UIColor object in the HSB colorspace. 795 | * 796 | * @since 1.0 797 | */ 798 | 799 | @property(class, nonatomic, readonly) UIColor *randomFlatColor; 800 | #else 801 | /** 802 | * Returns a randomly generated flat color object whose alpha value is 1.0. 803 | * 804 | * @return A flat @c UIColor object in the HSB colorspace. 805 | * 806 | * @since 1.0 807 | */ 808 | 809 | + (UIColor *)randomFlatColor; 810 | #endif 811 | 812 | /** 813 | * @author Vicc Alexander 814 | * 815 | * Returns a randomly generated flat color object NOT found in the specified array. 816 | * 817 | * @param colors An array specifying which colors NOT to return. 818 | * 819 | * @return A flat @c UIColor object in the HSB colorspace. 820 | * 821 | * @since 2.1.0 822 | */ 823 | + (UIColor *)colorWithRandomFlatColorExcludingColorsInArray:(NSArray * _Nonnull)colors; 824 | 825 | /** 826 | * @author Vicc Alexander 827 | * 828 | * Returns a randomly generated color object found in the specified array. 829 | * 830 | * @param colors An array specifying which colors to return. 831 | * 832 | * @return A flat @c UIColor object in the HSB colorspace. 833 | * 834 | * @since 2.1.0 835 | */ 836 | + (UIColor * _Nullable)colorWithRandomColorInArray:(NSArray * _Nonnull)colors; 837 | 838 | /** 839 | * Returns a randomly generated flat color object with an alpha value of 1.0 in either a light or dark shade. 840 | * 841 | * @param shadeStyle Specifies whether the randomly generated flat color should be a light or dark shade. 842 | * 843 | * @return A flat @c UIColor object in the HSB colorspace. 844 | * 845 | * @since 1.0 846 | */ 847 | + (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle; 848 | 849 | /** 850 | * Returns a randomly generated flat color object in either a light or dark shade. 851 | * 852 | * @param shadeStyle Specifies whether the randomly generated flat color should be a light or dark shade. 853 | * @param alpha The opacity. 854 | * 855 | * @return A flat @c UIColor object in the HSB colorspace. 856 | * 857 | * @since 2.0 858 | */ 859 | + (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha; 860 | 861 | #pragma mark - Averaging a Color 862 | 863 | /** 864 | * Returns the average color generated by averaging the colors of a specified image. 865 | * 866 | * @param image A specified @c UIImage. 867 | * 868 | * @return A flat @c UIColor object in the HSB colorspace. 869 | * 870 | * @since 2.0 871 | */ 872 | + (UIColor *)colorWithAverageColorFromImage:(UIImage *)image; 873 | 874 | /** 875 | * Returns the average color generated by averaging the colors of a specified image. 876 | * 877 | * @param image A specified @c UIImage. 878 | * @param alpha The opacity. 879 | * 880 | * @return A flat @c UIColor object in the HSB colorspace. 881 | * 882 | * @since 2.0 883 | */ 884 | + (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha; 885 | 886 | #pragma mark - Complementary Colors 887 | 888 | /** 889 | * Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. 890 | * 891 | * @param color The color whose complementary color is being requested. 892 | * 893 | * @return A flat UIColor object in the HSB colorspace. 894 | * 895 | * @since 1.0 896 | */ 897 | 898 | + (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color; 899 | 900 | /** 901 | * Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. 902 | * 903 | * @param color The color whose complementary color is being requested. 904 | * @param alpha The opacity. 905 | * 906 | * @return A flat UIColor object in the HSB colorspace. 907 | * 908 | * @since 2.0 909 | */ 910 | 911 | + (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha; 912 | 913 | #pragma mark - Contrasting Colors 914 | 915 | /** 916 | * Creates and returns either a black or white color object depending on which contrasts more with a specified color. 917 | * 918 | * @param backgroundColor The specified color of the contrast color that is being requested. 919 | * @param flat Pass YES to return flat color objects. 920 | * 921 | * @return A UIColor object in the HSB colorspace. 922 | * 923 | * @since 1.0 924 | */ 925 | 926 | + (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat; 927 | 928 | /** 929 | * Creates and returns either a black or white color object depending on which contrasts more with a specified color. 930 | * 931 | * @param backgroundColor The specified color of the contrast color that is being requested. 932 | * @param flat Pass YES to return flat color objects. 933 | * @param alpha The opacity. 934 | * 935 | * @return A UIColor object in the HSB colorspace. 936 | * 937 | * @since 2.0 938 | */ 939 | + (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat alpha:(CGFloat)alpha; 940 | 941 | #pragma mark - Gradient Colors 942 | 943 | /** 944 | * Creates and returns a gradient as a color object with an alpha value of 1.0 945 | * 946 | * @param gradientStyle Specifies the style and direction of the gradual blend between colors. 947 | * @param frame The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. 948 | * @param colors An array of color objects used to create a gradient. 949 | * 950 | * @return A @c UIColor object using colorWithPattern. 951 | * 952 | * @since 2.0 953 | */ 954 | + (UIColor *)colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray * _Nonnull)colors; 955 | 956 | #pragma mark - Colors from Hex Strings 957 | 958 | /** 959 | * Creates and returns a @c UIColor object based on the specified hex string. 960 | * 961 | * @param string The hex string. 962 | * 963 | * @return A @c UIColor object in the RGB colorspace. 964 | * 965 | * 966 | * @since 2.0 967 | */ 968 | + (UIColor * _Nullable)colorWithHexString:(NSString* _Nonnull)string; 969 | 970 | /** 971 | * Creates and returns a @c UIColor object based on the specified hex string. 972 | * 973 | * @param string The hex string. 974 | * @param alpha The opacity. 975 | * 976 | * @return A @c UIColor object in the RGB colorspace. 977 | * 978 | * 979 | * @since 2.0 980 | */ 981 | + (UIColor * _Nullable)colorWithHexString:(NSString * _Nonnull)string withAlpha:(CGFloat)alpha; 982 | 983 | #pragma mark - Instance Methods 984 | 985 | /** 986 | * Creates and returns a flat color object closest to the specified color in the LAB colorspace. 987 | * 988 | * @return A flat version of the specified @c UIColor. 989 | * 990 | * @since 2.0 991 | */ 992 | - (UIColor *)flatten; 993 | 994 | /** 995 | * Creates and returns a darker shade of a specified color in the HSB space. 996 | * 997 | * @param percentage The value with which to darken a specified color. 998 | * 999 | * @return A @c UIColor object in the HSB space. 1000 | * 1001 | * @since 2.0 1002 | */ 1003 | - (UIColor * _Nullable)darkenByPercentage:(CGFloat)percentage; 1004 | 1005 | /** 1006 | * @author Vicc Alexander 1007 | * 1008 | * Returns the hex string value for the specified color. 1009 | * 1010 | * @return An @NSString object. 1011 | * 1012 | * @since 2.1.0 1013 | */ 1014 | - (NSString *)hexValue; 1015 | 1016 | /** 1017 | * Creates and returns a lighter shade of a specified color in the HSB space. 1018 | * 1019 | * @param percentage The value with which to lighten a specified color. 1020 | * 1021 | * @return A @c UIColor object in the HSB space. 1022 | * 1023 | * @since 2.0 1024 | */ 1025 | - (UIColor * _Nullable)lightenByPercentage:(CGFloat)percentage; 1026 | 1027 | #pragma mark - Deprecated Methods 1028 | 1029 | /** 1030 | * Creates and returns a flat color object closest to the specified color in the LAB colorspace. 1031 | * 1032 | * @param color The specified color of the flat color that is being requested. 1033 | * 1034 | * @return A flat UIColor object in the RGB colorspace. 1035 | * 1036 | * @since 1.0 1037 | */ 1038 | + (UIColor *)colorWithFlatVersionOf:(UIColor *)color __attribute((deprecated(" Use -flatten: instead (First deprecated in Chameleon 2.0)."))); 1039 | 1040 | 1041 | @end 1042 | 1043 | NS_ASSUME_NONNULL_END 1044 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+ChameleonPrivate.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/6/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UIColor (ChameleonPrivate) 13 | 14 | @property (nonatomic, readwrite) NSUInteger count; 15 | 16 | #pragma mark - Class Methods 17 | 18 | + (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point; 19 | 20 | - (UIColor *)colorWithMinimumSaturation:(CGFloat)saturation; 21 | 22 | #pragma mark - Instance Methods 23 | 24 | - (BOOL)isDistinct:(UIColor *)color; 25 | 26 | - (BOOL)getValueForX:(CGFloat *)X 27 | valueForY:(CGFloat *)Y 28 | valueForZ:(CGFloat *)Z 29 | alpha:(CGFloat *)alpha; 30 | 31 | - (BOOL)getLightness:(CGFloat *)L 32 | valueForA:(CGFloat *)A 33 | valueForB:(CGFloat *)B 34 | alpha:(CGFloat *)alpha; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+ChameleonPrivate.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/6/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UIColor+ChameleonPrivate.h" 10 | 11 | @implementation UIColor (ChameleonPrivate) 12 | 13 | @dynamic count; 14 | 15 | #pragma mark - Associated Objects Methods 16 | 17 | - (void)setCount:(NSUInteger)count { 18 | objc_setAssociatedObject(self, @selector(count), [NSNumber numberWithUnsignedInteger:count], OBJC_ASSOCIATION_RETAIN_NONATOMIC); 19 | } 20 | 21 | - (NSUInteger)count { 22 | NSNumber *number = objc_getAssociatedObject(self, @selector(count)); 23 | return [number unsignedIntegerValue]; 24 | } 25 | 26 | #pragma mark - Class Methods 27 | 28 | // Would not have been possible without - http://stackoverflow.com/a/1262893 29 | + (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point { 30 | 31 | //Encapsulate our image 32 | CGImageRef imageRef = image.CGImage; 33 | NSUInteger width = CGImageGetWidth(imageRef); 34 | NSUInteger height = CGImageGetHeight(imageRef); 35 | 36 | //Specify the colorspace we're in 37 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 38 | 39 | //Extract the data we need 40 | unsigned char *rawData = calloc(height * width * 4, sizeof(unsigned char)); 41 | NSUInteger bytesPerPixel = 4; 42 | NSUInteger bytesPerRow = bytesPerPixel * width; 43 | NSUInteger bitsPerComponent = 8; 44 | CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, 45 | colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 46 | //Release colorspace 47 | CGColorSpaceRelease(colorSpace); 48 | 49 | //Draw and release image 50 | CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); 51 | CGContextRelease(context); 52 | 53 | //rawData now contains the image data in RGBA8888 54 | NSInteger byteIndex = (bytesPerRow * point.y) + (point.x * bytesPerPixel); 55 | 56 | //Define our RGBA values 57 | CGFloat red = (rawData[byteIndex] * 1.f) / 255.f; 58 | CGFloat green = (rawData[byteIndex + 1] * 1.f) / 255.f; 59 | CGFloat blue = (rawData[byteIndex + 2] * 1.f) / 255.f; 60 | CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.f; 61 | 62 | //Free our rawData 63 | free(rawData); 64 | 65 | //Return color 66 | return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 67 | } 68 | 69 | - (UIColor *)colorWithMinimumSaturation:(CGFloat)saturation { 70 | if (!self) 71 | return nil; 72 | 73 | CGFloat h, s, b, a; 74 | [self getHue:&h saturation:&s brightness:&b alpha:&a]; 75 | 76 | if (s < saturation) 77 | return [UIColor colorWithHue:h saturation:saturation brightness:b alpha:a]; 78 | 79 | return self; 80 | } 81 | 82 | #pragma mark - Instance Methods 83 | 84 | - (BOOL)isDistinct:(UIColor *)color { 85 | 86 | if (!self || !color) { 87 | return NO; 88 | } 89 | 90 | CGFloat r, g, b, a; 91 | CGFloat rc, gc, bc, ac; 92 | 93 | [self getRed:&r green:&g blue:&b alpha:&a]; 94 | [color getRed:&rc green:&gc blue:&bc alpha:&ac]; 95 | 96 | CGFloat threshold = 0.25f; 97 | 98 | if (fabs(r - rc) > threshold || fabs(g - gc) > threshold || 99 | 100 | fabs(b - bc) > threshold || fabs(a - ac) > threshold) { 101 | 102 | // Check for grays 103 | if (fabs(r - g) < 0.03f && fabs(r - b) < 0.03f) { 104 | 105 | if (fabs(rc - gc) < 0.03f && (fabs(rc - bc) < 0.03f)) { 106 | return NO; 107 | } 108 | 109 | } 110 | 111 | return YES; 112 | } 113 | 114 | return NO; 115 | } 116 | 117 | - (BOOL)getValueForX:(CGFloat *)X valueForY:(CGFloat *)Y valueForZ:(CGFloat *)Z alpha:(CGFloat *)alpha{ 118 | 119 | if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) { 120 | 121 | //Get RGB values from the input color 122 | CGFloat red = 0, green = 0, blue = 0, alpha1 = 0; 123 | [self getRed:&red green:&green blue:&blue alpha:&alpha1]; 124 | 125 | //Run our input color's RGB values through the XYZ algorithm to convert them into XYZ values 126 | NSArray *XYZValues = [self arrayOfXYZValuesForR:red G:green B:blue A:alpha1]; 127 | *X = [XYZValues[0] floatValue]; 128 | *Y = [XYZValues[1] floatValue]; 129 | *Z = [XYZValues[2] floatValue]; 130 | *alpha = [XYZValues[3] floatValue]; 131 | 132 | return YES; 133 | } 134 | 135 | return NO; 136 | } 137 | 138 | - (BOOL)getLightness:(CGFloat *)L valueForA:(CGFloat *)A valueForB:(CGFloat *)B alpha:(CGFloat *)alpha { 139 | 140 | if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) { 141 | 142 | //Get RGB values from the input color 143 | CGFloat red = 0, green = 0, blue = 0, alpha1 = 0; 144 | [self getRed:&red green:&green blue:&blue alpha:&alpha1]; 145 | 146 | //Run our input color's RGB values through the XYZ algorithm to convert them into XYZ values 147 | NSArray *XYZValues = [self arrayOfXYZValuesForR:red G:green B:blue A:alpha1]; 148 | CGFloat X = [XYZValues[0] floatValue]; 149 | CGFloat Y = [XYZValues[1] floatValue]; 150 | CGFloat Z = [XYZValues[2] floatValue]; 151 | 152 | if (L != nil && A != nil && B != nil) { 153 | //Run our new XYZ values through our LAB algorithm to convert them into LAB values 154 | NSArray *LABValues = [self arrayOfLABValuesForX:X Y:Y Z:Z alpha:alpha1]; 155 | *L = [LABValues[0] floatValue]; 156 | *A = [LABValues[1] floatValue]; 157 | *B = [LABValues[2] floatValue]; 158 | } 159 | 160 | return YES; 161 | } 162 | 163 | return NO; 164 | } 165 | 166 | #pragma mark - Internal Helper Methods 167 | 168 | - (NSArray *)arrayOfXYZValuesForR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha { 169 | 170 | /* 171 | Let's begin by converting from RGB to sRGB. 172 | We're going to use the Reverse Transformation Equation. 173 | http://en.wikipedia.org/wiki/SRGB 174 | */ 175 | 176 | void (^sRGB)(CGFloat *C); 177 | sRGB = ^(CGFloat *C) { 178 | if (*C > 0.04045) { 179 | *C = pow(((*C + 0.055)/ (1 + 0.055)), 2.40); 180 | } else { 181 | *C /= 12.92; 182 | } 183 | }; 184 | 185 | sRGB(&red); 186 | sRGB(&green); 187 | sRGB(&blue); 188 | 189 | /* 190 | Now we're going to convert to XYZ values, using a matrix multiplication of the linear values 191 | http://upload.wikimedia.org/math/4/3/3/433376fc18cccd887758beffb7e7c625.png 192 | */ 193 | 194 | CGFloat X = (red * 0.4124) + (green * 0.3576) + (blue * 0.1805); 195 | CGFloat Y = (red * 0.2126) + (green * 0.7152) + (blue * 0.0722); 196 | CGFloat Z = (red * 0.0193) + (green * 0.1192) + (blue * 0.9505); 197 | 198 | X *= 100; 199 | Y *= 100; 200 | Z *= 100; 201 | 202 | return @[@(X), @(Y), @(Z), @(alpha)]; 203 | } 204 | 205 | - (NSArray *)arrayOfLABValuesForX:(CGFloat)X Y:(CGFloat)Y Z:(CGFloat)Z alpha:(CGFloat)alpha { 206 | 207 | /* 208 | The corresponding original XYZ values are such that white is D65 with unit luminance (X,Y,Z = 0.9505, 1.0000, 1.0890). 209 | Calculations are also to assume the 2° standard colorimetric observer. 210 | D65: http://en.wikipedia.org/wiki/CIE_Standard_Illuminant_D65 211 | Standard Colorimetric Observer: http://en.wikipedia.org/wiki/Standard_colorimetric_observer#CIE_standard_observer 212 | 213 | Since we mutiplied our XYZ values by 100 to produce a percentage we should also multiply our unit luminance values by 100. 214 | */ 215 | 216 | X /= (0.9505 * 100); 217 | Y /= (1.0000 * 100); 218 | Z /= (1.0890 * 100); 219 | 220 | /* 221 | Next we need to use the forward transformation function for CIELAB-CIEXYZ conversions 222 | Function: http://upload.wikimedia.org/math/e/5/1/e513d25d50d406bfffb6ed3c854bd8a4.png 223 | */ 224 | 225 | void (^XYZtoLAB)(CGFloat *f); 226 | XYZtoLAB = ^(CGFloat *f) { 227 | if ((*f > pow((6.0/29.0), 3.0)) ) { 228 | *f = pow(*f, 1.0/3.0); 229 | } else { 230 | *f = (1/3)*pow((29.0/6.0), 2.0) * *f + 4/29.0; 231 | } 232 | }; 233 | 234 | XYZtoLAB(&X); 235 | XYZtoLAB(&Y); 236 | XYZtoLAB(&Z); 237 | 238 | /* 239 | Next we get our LAB values using the following equations and the results from the function above 240 | http://upload.wikimedia.org/math/0/0/6/006164b74314e2fdcdc34ac9d0aa6fe4.png 241 | */ 242 | 243 | CGFloat L = (116 * Y) - 16; 244 | CGFloat A = 500 * (X - Y); 245 | CGFloat B = 200 * (Y - Z); 246 | 247 | 248 | return @[@(L), @(A), @(B), @(alpha)]; 249 | } 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ChameleonPrivate.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/8/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (ChameleonPrivate) 12 | 13 | #pragma mark - Class Methods 14 | 15 | + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize; 16 | 17 | #pragma mark - Instance Methods 18 | 19 | - (UIImage *)imageScaledToSize:(CGSize)newSize; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ChameleonPrivate.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/8/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UIImage+ChameleonPrivate.h" 10 | 11 | @implementation UIImage (ChameleonPrivate) 12 | 13 | // Would not have been possible without - http://stackoverflow.com/a/1262893 14 | + (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point { 15 | 16 | //Encapsulate our image 17 | CGImageRef imageRef = image.CGImage; 18 | NSUInteger width = CGImageGetWidth(imageRef); 19 | NSUInteger height = CGImageGetHeight(imageRef); 20 | 21 | //Specify the colorspace we're in 22 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 23 | 24 | //Extract the data we need 25 | unsigned char *rawData = calloc(height * width * 4, sizeof(unsigned char)); 26 | NSUInteger bytesPerPixel = 4; 27 | NSUInteger bytesPerRow = bytesPerPixel * width; 28 | NSUInteger bitsPerComponent = 8; 29 | CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, 30 | colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 31 | //Release colorspace 32 | CGColorSpaceRelease(colorSpace); 33 | 34 | //Draw and release image 35 | CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); 36 | CGContextRelease(context); 37 | 38 | //rawData now contains the image data in RGBA8888 39 | NSInteger byteIndex = (bytesPerRow * point.y) + (point.x * bytesPerPixel); 40 | 41 | //Define our RGBA values 42 | CGFloat red = (rawData[byteIndex] * 1.f) / 255.f; 43 | CGFloat green = (rawData[byteIndex + 1] * 1.f) / 255.f; 44 | CGFloat blue = (rawData[byteIndex + 2] * 1.f) / 255.f; 45 | CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.f; 46 | 47 | //Free our rawData 48 | free(rawData); 49 | 50 | //Return color 51 | return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 52 | } 53 | 54 | + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize { 55 | 56 | UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0); 57 | [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; 58 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 59 | UIGraphicsEndImageContext(); 60 | return newImage; 61 | } 62 | 63 | #pragma mark - Instance Methods 64 | 65 | - (UIImage *)imageScaledToSize:(CGSize)newSize { 66 | 67 | UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0); 68 | [self drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; 69 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 70 | UIGraphicsEndImageContext(); 71 | return newImage; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UILabel+Chameleon.h: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+Chameleon.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 9/20/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UILabel (Chameleon) 12 | 13 | - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UILabel+Chameleon.m: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+Chameleon.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 9/20/15. 6 | // Copyright © 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UILabel+Chameleon.h" 10 | 11 | @implementation UILabel (Chameleon) 12 | 13 | - (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR { 14 | 15 | self.font = [UIFont fontWithName:name size:self.font.pointSize]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UINavigationController+Chameleon.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+Chameleon.h 3 | // ChameleonDemo 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ChameleonEnums.h" 11 | 12 | @interface UINavigationController (Chameleon) 13 | 14 | /** 15 | * Sets the status bar style for the specified @c UINavigationController and all its child controllers. 16 | * 17 | * @param statusBarStyle The style of the device's status bar. 18 | * 19 | * @note Chameleon introduces a new @c statusBarStyle called @c UIStatusBarStyleContrast. 20 | * 21 | * @since 2.0 22 | */ 23 | - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; 24 | 25 | /** 26 | * Hides the hairline view at the bottom of a navigation bar. The default value is @c NO. 27 | * 28 | * @since 2.0.3 29 | */ 30 | @property (nonatomic, assign) BOOL hidesNavigationBarHairline; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UINavigationController+Chameleon.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+Chameleon.m 3 | // ChameleonDemo 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UINavigationController+Chameleon.h" 10 | #import 11 | 12 | #import "ChameleonConstants.h" 13 | #import "ChameleonEnums.h" 14 | #import "ChameleonMacros.h" 15 | 16 | #import "NSArray+Chameleon.h" 17 | #import "UIColor+Chameleon.h" 18 | #import "UIViewController+Chameleon.h" 19 | 20 | @interface UINavigationController () 21 | 22 | @property (readwrite) BOOL shouldContrast; 23 | @property (readwrite) BOOL shouldUseLightContent; 24 | 25 | @end 26 | 27 | @implementation UINavigationController (Chameleon) 28 | 29 | @dynamic hidesNavigationBarHairline; 30 | 31 | #pragma mark - Swizzling 32 | 33 | + (void)load { 34 | 35 | static dispatch_once_t onceToken; 36 | dispatch_once(&onceToken, ^{ 37 | 38 | Class class = [self class]; 39 | 40 | SEL originalSelector = @selector(viewDidLoad); 41 | SEL swizzledSelector = @selector(chameleon_viewDidLoad); 42 | 43 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 44 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 45 | 46 | BOOL didAddMethod = 47 | class_addMethod(class, 48 | originalSelector, 49 | method_getImplementation(swizzledMethod), 50 | method_getTypeEncoding(swizzledMethod)); 51 | 52 | if (didAddMethod) { 53 | class_replaceMethod(class, 54 | swizzledSelector, 55 | method_getImplementation(originalMethod), 56 | method_getTypeEncoding(originalMethod)); 57 | 58 | } else { 59 | method_exchangeImplementations(originalMethod, swizzledMethod); 60 | } 61 | }); 62 | } 63 | 64 | - (void)chameleon_viewDidLoad { 65 | 66 | [self chameleon_viewDidLoad]; 67 | 68 | UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; 69 | 70 | if (hairlineImageView) { 71 | 72 | if (self.hidesNavigationBarHairline) { 73 | hairlineImageView.hidden = YES; 74 | 75 | } else { 76 | hairlineImageView.hidden = NO; 77 | } 78 | } 79 | } 80 | 81 | - (UIImageView *)findHairlineImageViewUnder:(UIView *)view { 82 | 83 | if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) { 84 | return (UIImageView *)view; 85 | } 86 | 87 | for (UIView *subview in view.subviews) { 88 | UIImageView *imageView = [self findHairlineImageViewUnder:subview]; 89 | if (imageView) { 90 | return imageView; 91 | } 92 | } 93 | 94 | return nil; 95 | } 96 | 97 | #pragma mark - Runtime 98 | 99 | - (void)setShouldContrast:(BOOL)contrast { 100 | 101 | NSNumber *number = [NSNumber numberWithBool:contrast]; 102 | objc_setAssociatedObject(self, @selector(shouldContrast), number, OBJC_ASSOCIATION_RETAIN); 103 | } 104 | 105 | - (BOOL)shouldContrast { 106 | 107 | NSNumber *number = objc_getAssociatedObject(self, @selector(shouldContrast)); 108 | return [number boolValue]; 109 | } 110 | 111 | - (void)setShouldUseLightContent:(BOOL)shouldUseLightContent { 112 | 113 | NSNumber *number = [NSNumber numberWithBool:shouldUseLightContent]; 114 | objc_setAssociatedObject(self, @selector(shouldUseLightContent), number, OBJC_ASSOCIATION_RETAIN); 115 | } 116 | 117 | - (BOOL)shouldUseLightContent { 118 | 119 | NSNumber *number = objc_getAssociatedObject(self, @selector(shouldUseLightContent)); 120 | return [number boolValue]; 121 | } 122 | 123 | - (void)setHidesNavigationBarHairline:(BOOL)hidesNavigationBarHairline { 124 | 125 | NSNumber *number = [NSNumber numberWithBool:hidesNavigationBarHairline]; 126 | objc_setAssociatedObject(self, @selector(hidesNavigationBarHairline), number, OBJC_ASSOCIATION_RETAIN); 127 | 128 | //Find Hairline Image 129 | UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; 130 | 131 | //Check if it exists 132 | if (hairlineImageView) { 133 | 134 | //Check if we should hide it or not 135 | if (hidesNavigationBarHairline) { 136 | hairlineImageView.hidden = YES; 137 | 138 | } else { 139 | hairlineImageView.hidden = NO; 140 | } 141 | } 142 | } 143 | 144 | - (BOOL)hidesNavigationBarHairline { 145 | 146 | NSNumber *number = objc_getAssociatedObject(self, @selector(hidesNavigationBarHairline)); 147 | return [number boolValue]; 148 | } 149 | 150 | 151 | #pragma mark - Public Methods 152 | 153 | - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { 154 | 155 | if (statusBarStyle == UIStatusBarStyleContrast) { 156 | 157 | self.shouldContrast = YES; 158 | 159 | } else { 160 | 161 | if (statusBarStyle == UIStatusBarStyleLightContent) { 162 | 163 | self.shouldUseLightContent = YES; 164 | 165 | } else { 166 | 167 | self.shouldUseLightContent = NO; 168 | } 169 | 170 | } 171 | } 172 | 173 | #pragma mark - Private Methods 174 | 175 | - (UIStatusBarStyle)preferredStatusBarStyle { 176 | 177 | [super preferredStatusBarStyle]; 178 | 179 | if (self.shouldContrast) { 180 | 181 | return [self contrastingStatusBarStyleForColor:self.navigationBar.barTintColor]; 182 | 183 | } else { 184 | 185 | if (self.shouldUseLightContent) { 186 | 187 | return UIStatusBarStyleLightContent; 188 | 189 | } else { 190 | 191 | return UIStatusBarStyleDefault; 192 | } 193 | } 194 | } 195 | 196 | - (UIStatusBarStyle)contrastingStatusBarStyleForColor:(UIColor *)backgroundColor { 197 | 198 | //Calculate Luminance 199 | CGFloat luminance; 200 | CGFloat red, green, blue; 201 | 202 | //Check for clear or uncalculatable color and assume white 203 | if (![backgroundColor getRed:&red green:&green blue:&blue alpha:nil]) { 204 | return UIStatusBarStyleDefault; 205 | } 206 | 207 | //Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) 208 | red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; 209 | luminance = red + green + blue; 210 | 211 | return (luminance > 0.6f) ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; 212 | } 213 | 214 | @end 215 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIView+ChameleonPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+ChameleonPrivate.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (ChameleonPrivate) 12 | 13 | - (BOOL)isTopViewInWindow; 14 | - (UIView *)findTopMostViewForPoint:(CGPoint)point; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIView+ChameleonPrivate.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+ChameleonPrivate.m 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import "UIView+ChameleonPrivate.h" 10 | 11 | @implementation UIView (ChameleonPrivate) 12 | 13 | - (BOOL)isTopViewInWindow { 14 | 15 | if (!self.window) { 16 | return NO; 17 | } 18 | 19 | CGPoint centerPointInSelf = CGPointMake(CGRectGetMidX(self.bounds), 20 | CGRectGetMidY(self.bounds)); 21 | 22 | CGPoint centerPointOfSelfInWindow = [self convertPoint:centerPointInSelf 23 | toView:self.window]; 24 | 25 | UIView *view = [self.window findTopMostViewForPoint:centerPointOfSelfInWindow]; 26 | BOOL isTopMost = view == self || [view isDescendantOfView:self]; 27 | 28 | return isTopMost; 29 | } 30 | 31 | - (UIView *)findTopMostViewForPoint:(CGPoint)point { 32 | 33 | for (int i = (int)self.subviews.count - 1; i >= 0; i--) { 34 | 35 | UIView *subview = self.subviews[i]; 36 | 37 | if (!subview.hidden && CGRectContainsPoint(subview.frame, point) && subview.alpha > 0.01) { 38 | CGPoint pointConverted = [self convertPoint:point toView:subview]; 39 | return [subview findTopMostViewForPoint:pointConverted]; 40 | } 41 | } 42 | 43 | return self; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pod/Classes/Objective-C/UIViewController+Chameleon.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+Chameleon.h 3 | // Chameleon 4 | // 5 | // Created by Vicc Alexander on 6/4/15. 6 | // Copyright (c) 2015 Vicc Alexander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ChameleonEnums.h" 11 | 12 | @interface UIViewController (Chameleon) 13 | 14 | /** 15 | * Sets the color theme for the specified view controller using a primary color and the specified content style. 16 | * 17 | * @param primaryColor The primary color. 18 | * @param contentStyle The contentStyle. 19 | * 20 | * @since 2.0 21 | */ 22 | - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor 23 | withContentStyle:(UIContentStyle)contentStyle; 24 | 25 | /** 26 | * Sets the color theme for the specified view controller using a primary color, secondary color, and the specified content style. 27 | * 28 | * @param primaryColor The primary color. 29 | * @param secondaryColor The secondary color. 30 | * @param contentStyle The contentStyle. 31 | * 32 | * @since 2.0 33 | */ 34 | - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor 35 | withSecondaryColor:(UIColor *)secondaryColor 36 | andContentStyle:(UIContentStyle)contentStyle; 37 | 38 | /** 39 | * Sets the color theme for the specified view controller using a primary color, secondary color, font name, and the specified content style. 40 | * 41 | * @param primaryColor The primary color. 42 | * @param secondaryColor The secondary color. 43 | * @param fontName The main font to use for all text-based elements. 44 | * @param contentStyle The contentStyle. 45 | * 46 | * @since 2.0 47 | */ 48 | - (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor 49 | withSecondaryColor:(UIColor *)secondaryColor 50 | usingFontName:(NSString *)fontName 51 | andContentStyle:(UIContentStyle)contentStyle; 52 | 53 | /** 54 | * Sets the status bar style for the specified @c UIViewController and all its child controllers. 55 | * 56 | * @param statusBarStyle The style of the device's status bar. 57 | * 58 | * @note Chameleon introduces a new @c statusBarStyle called @c UIStatusBarStyleContrast. 59 | * 60 | * @since 2.0 61 | */ 62 | - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Pod/Classes/Swift/ChameleonShorthand.swift: -------------------------------------------------------------------------------- 1 | 2 | // ChameleonShorthand.swift 3 | 4 | /* 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2014-2015 Vicc Alexander. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | import UIKit 31 | 32 | // MARK: - UIColor Methods Shorthand 33 | 34 | /** 35 | Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. 36 | 37 | - parameter color: The color whose complementary color is being requested. 38 | 39 | - returns: A flat UIColor object in the HSB colorspace. 40 | */ 41 | public func ComplementaryFlatColorOf(_ color: UIColor) -> UIColor { 42 | return UIColor(complementaryFlatColorOf: color) 43 | } 44 | 45 | /** 46 | Returns a randomly generated flat color object with an alpha value of 1.0 in either a light or dark shade. 47 | 48 | - parameter shade: Specifies whether the randomly generated flat color should be a light or dark shade. 49 | 50 | - returns: A flat UIColor object in the HSB colorspace. 51 | */ 52 | public func RandomFlatColorWithShade(_ shade: UIShadeStyle) -> UIColor { 53 | return UIColor(randomFlatColorOf: shade) 54 | } 55 | 56 | /** 57 | Creates and returns either a black or white color object depending on which contrasts more with a specified color. 58 | 59 | - parameter backgroundColor: The specified color of the contrast color that is being requested. 60 | - parameter returnFlat: Pass **true** to return flat color objects. 61 | 62 | - returns: A UIColor object in the HSB colorspace. 63 | */ 64 | public func ContrastColorOf(_ backgroundColor: UIColor, returnFlat: Bool) -> UIColor { 65 | return UIColor(contrastingBlackOrWhiteColorOn: backgroundColor, isFlat: returnFlat) 66 | } 67 | 68 | /** 69 | Creates and returns a gradient as a color object with an alpha value of 1.0 70 | 71 | - parameter gradientStyle: Specifies the style and direction of the gradual blend between colors. 72 | - parameter frame: The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. 73 | - parameter colors: An array of color objects used to create a gradient. 74 | 75 | - returns: A UIColor object using colorWithPattern. 76 | */ 77 | public func GradientColor(_ gradientStyle: UIGradientStyle, frame: CGRect, colors: [UIColor]) -> UIColor { 78 | return UIColor(gradientStyle: gradientStyle, withFrame: frame, andColors: colors) 79 | } 80 | 81 | public func HexColor(_ hexString: String, _ alpha: CGFloat = 1.0) -> UIColor? { 82 | return UIColor(hexString: hexString, withAlpha: alpha) 83 | } 84 | 85 | /** 86 | Returns the average color generated by averaging the colors of a specified image. 87 | 88 | - parameter image: A specified UIImage. 89 | 90 | - returns: A flat UIColor object in the HSB colorspace. 91 | */ 92 | public func AverageColorFromImage(_ image: UIImage) -> UIColor { 93 | return UIColor(averageColorFrom: image) 94 | } 95 | 96 | // MARK: - Array Methods Shorthand 97 | 98 | // TODO Array Extension needed ;) 99 | 100 | /** 101 | Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. 102 | 103 | - parameter colorSchemeType: The color scheme with which to select colors using a specified color. 104 | - parameter color: The specified color which the color scheme is built around. 105 | - parameter isFlatScheme: Pass *true* to return flat color objects. 106 | 107 | - returns: An array of 5 color objects in the HSB colorspace. 108 | */ 109 | public func ColorSchemeOf(_ colorSchemeType:ColorScheme, color:UIColor, isFlatScheme:Bool) -> [UIColor] { 110 | return NSArray(ofColorsWith: colorSchemeType, using: color, withFlatScheme: isFlatScheme) as! [UIColor] 111 | } 112 | 113 | /** 114 | Generates and creates an array of 5 color objects in the HSB colorspace that appear most often in a specified image. 115 | 116 | - parameter image: The specified image which the color scheme is built around. 117 | - parameter withFlatScheme: Pass **true** to return flat color objects. 118 | 119 | - returns: An array of 5 color objects in the HSB colorspace. 120 | */ 121 | public func ColorsFromImage(_ image: UIImage, withFlatScheme: Bool) -> [UIColor] { 122 | // TODO: Remove forced casting 123 | return NSArray(ofColorsFrom: image, withFlatScheme: withFlatScheme) as! [UIColor] 124 | } 125 | 126 | 127 | // MARK: - Special Colors Shorthand 128 | 129 | /** 130 | Returns a randomly generated flat color object whose alpha value is 1.0. 131 | 132 | - returns: A flat UIColor object in the HSB colorspace. 133 | */ 134 | public func RandomFlatColor() -> UIColor { 135 | return UIColor.randomFlat 136 | } 137 | 138 | public func ClearColor() -> UIColor { 139 | return UIColor.clear 140 | } 141 | 142 | 143 | // MARK: - Light Shades Shorthand 144 | 145 | public func FlatBlack() -> UIColor { 146 | return UIColor.flatBlack 147 | } 148 | 149 | public func FlatBlue() -> UIColor { 150 | return UIColor.flatBlue 151 | } 152 | 153 | public func FlatBrown() -> UIColor { 154 | return UIColor.flatBrown 155 | } 156 | 157 | public func FlatCoffee() -> UIColor { 158 | return UIColor.flatCoffee 159 | } 160 | 161 | public func FlatForestGreen() -> UIColor { 162 | return UIColor.flatForestGreen 163 | } 164 | 165 | public func FlatGray() -> UIColor { 166 | return UIColor.flatGray 167 | } 168 | 169 | public func FlatGreen() -> UIColor { 170 | return UIColor.flatGreen 171 | } 172 | 173 | public func FlatLime() -> UIColor { 174 | return UIColor.flatLime 175 | } 176 | 177 | public func FlatMagenta() -> UIColor { 178 | return UIColor.flatMagenta 179 | } 180 | 181 | public func FlatMaroon() -> UIColor { 182 | return UIColor.flatMaroon 183 | } 184 | 185 | public func FlatMint() -> UIColor { 186 | return UIColor.flatMint 187 | } 188 | 189 | public func FlatNavyBlue() -> UIColor { 190 | return UIColor.flatNavyBlue 191 | } 192 | 193 | public func FlatOrange() -> UIColor { 194 | return UIColor.flatOrange 195 | } 196 | 197 | public func FlatPink() -> UIColor { 198 | return UIColor.flatPink 199 | } 200 | 201 | public func FlatPlum() -> UIColor { 202 | return UIColor.flatPlum 203 | } 204 | 205 | public func FlatPowderBlue() -> UIColor { 206 | return UIColor.flatPowderBlue 207 | } 208 | 209 | public func FlatPurple() -> UIColor { 210 | return UIColor.flatPurple 211 | } 212 | 213 | public func FlatRed() -> UIColor { 214 | return UIColor.flatRed 215 | } 216 | 217 | public func FlatSand() -> UIColor { 218 | return UIColor.flatSand 219 | } 220 | 221 | public func FlatSkyBlue() -> UIColor { 222 | return UIColor.flatSkyBlue 223 | } 224 | 225 | public func FlatTeal() -> UIColor { 226 | return UIColor.flatTeal 227 | } 228 | 229 | public func FlatWatermelon() -> UIColor { 230 | return UIColor.flatWatermelon 231 | } 232 | 233 | public func FlatWhite() -> UIColor { 234 | return UIColor.flatWhite 235 | } 236 | 237 | public func FlatYellow() -> UIColor { 238 | return UIColor.flatYellow 239 | } 240 | 241 | // MARK: - Chameleon - Dark Shades Shorthand 242 | 243 | public func FlatBlackDark() -> UIColor { 244 | return UIColor.flatBlackDark 245 | } 246 | 247 | public func FlatBlueDark() -> UIColor { 248 | return UIColor.flatBlueDark 249 | } 250 | 251 | public func FlatBrownDark() -> UIColor { 252 | return UIColor.flatBrownDark 253 | } 254 | 255 | public func FlatCoffeeDark() -> UIColor { 256 | return UIColor.flatCoffeeDark 257 | } 258 | 259 | public func FlatForestGreenDark() -> UIColor { 260 | return UIColor.flatForestGreenDark 261 | } 262 | 263 | public func FlatGrayDark() -> UIColor { 264 | return UIColor.flatGrayDark 265 | } 266 | 267 | public func FlatGreenDark() -> UIColor { 268 | return UIColor.flatGreenDark 269 | } 270 | 271 | public func FlatLimeDark() -> UIColor { 272 | return UIColor.flatLimeDark 273 | } 274 | 275 | public func FlatMagentaDark() -> UIColor { 276 | return UIColor.flatMagentaDark 277 | } 278 | 279 | public func FlatMaroonDark() -> UIColor { 280 | return UIColor.flatMaroonDark 281 | } 282 | 283 | public func FlatMintDark() -> UIColor { 284 | return UIColor.flatMintDark 285 | } 286 | 287 | public func FlatNavyBlueDark() -> UIColor { 288 | return UIColor.flatNavyBlueDark 289 | } 290 | 291 | public func FlatOrangeDark() -> UIColor { 292 | return UIColor.flatOrangeDark 293 | } 294 | 295 | public func FlatPinkDark() -> UIColor { 296 | return UIColor.flatPinkDark 297 | } 298 | 299 | public func FlatPlumDark() -> UIColor { 300 | return UIColor.flatPlumDark 301 | } 302 | 303 | public func FlatPowderBlueDark() -> UIColor { 304 | return UIColor.flatPowderBlueDark 305 | } 306 | 307 | public func FlatPurpleDark() -> UIColor { 308 | return UIColor.flatPurpleDark 309 | } 310 | 311 | public func FlatRedDark() -> UIColor { 312 | return UIColor.flatRedDark 313 | } 314 | 315 | public func FlatSandDark() -> UIColor { 316 | return UIColor.flatSandDark 317 | } 318 | 319 | public func FlatSkyBlueDark() -> UIColor { 320 | return UIColor.flatSkyBlueDark 321 | } 322 | 323 | public func FlatTealDark() -> UIColor { 324 | return UIColor.flatTealDark 325 | } 326 | 327 | public func FlatWatermelonDark() -> UIColor { 328 | return UIColor.flatWatermelonDark 329 | } 330 | 331 | public func FlatWhiteDark() -> UIColor { 332 | return UIColor.flatWhiteDark 333 | } 334 | 335 | public func FlatYellowDark() -> UIColor { 336 | return UIColor.flatYellowDark 337 | } 338 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Chameleon by Vicc Alexander 3 |

4 | 5 |

6 | Downloads 7 | Apps 8 | Platform: iOS 8+ 9 | Language: Swift 3 10 | Carthage compatible 11 | CocoaPods compatible 12 | License: MIT

13 |

14 | 15 | ## Swift 3 16 | 17 | To use the Swift 3 version, add this to your Podfile (until 2.2 or higher is released): 18 | ```ruby 19 | pod 'ChameleonFramework/Swift', :git => 'https://github.com/ViccAlexander/Chameleon.git' 20 | ``` 21 | 22 | ## Introduction 23 | 24 | **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. 25 | 26 | 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. 27 | 28 | ### Features 29 | 30 |

31 | Features 32 |

33 | 34 | ### App Showcase 35 | 36 | ###### 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). 37 | 38 | ## Table of Contents 39 | [● Product Features](https://github.com/ViccAlexander/Chameleon#-product-features) 40 | [● Requirements](https://github.com/ViccAlexander/Chameleon#%EF%B8%8F-requirements) 41 | [● License](https://github.com/ViccAlexander/Chameleon#-license) 42 | [● Contributions](https://github.com/ViccAlexander/Chameleon#-contributions) 43 | [● Documentation](https://github.com/ViccAlexander/Chameleon#-documentation) 44 | [● Storyboard Add-On](https://github.com/ViccAlexander/Chameleon#storyboard-add-on) 45 | [● Author](https://github.com/ViccAlexander/Chameleon#-author) 46 | [● To Do List](https://github.com/ViccAlexander/Chameleon#-to-do-list) 47 | [● Change Log](https://github.com/ViccAlexander/Chameleon#-change-log) 48 | 49 | ## 🌟 Product Features 50 | 51 | ### 100% Flat & Gorgeous 52 | 53 | Chameleon features over 24 hand-picked colors that come in both light and dark shades. 54 | 55 |

56 | Swatches 57 |

58 | 59 | ### Flat Color Schemes 60 | 61 | 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.* 62 | 63 | ###### Analogous Flat Color Scheme 64 | 65 |

66 | Analogous Scheme 67 |

68 | 69 | ###### Complementary Flat Color Scheme 70 |

71 | Complementary Scheme 72 |

73 | 74 | ###### Triadic Flat Color Scheme 75 |

76 | Triadic Scheme 77 |

78 | 79 | ### Contrasting Text 80 | 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. 81 | 82 | Oh... Chameleon works with the status bar as well. : ) 83 | 84 |

85 | Status Bar 86 |

87 | 88 | ### Themes ![Beta](http://i.imgur.com/JyYiUJq.png) 89 | 90 | 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. 91 | 92 |

93 | Themes 94 |

95 | 96 | ### Colors From Images 97 | 98 | 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! 99 | 100 |

101 | Colors from images 102 |

103 | 104 | ### Gradient Colors 105 | 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! 106 | 107 |

108 | Gradients 109 |

110 | 111 | ![](http://i.imgur.com/2jN72eh.png) 112 | 113 | ### Xcode Quick Help Documentation 114 | 115 | 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! 116 | 117 |

118 | Xcode Quick Help Documentation 119 |

120 | 121 | ### Palettes 122 | 123 | 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. 124 | 125 |

126 | Chameleon Palette 127 |

128 | 129 |

130 | Chameleon Palette 131 |

132 | 133 | ## ⚠️ Requirements 134 | 135 | * Objective-C or Swift 136 | * 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. 137 | * Requires Xcode 6.3 for use in any iOS Project 138 | 139 | ## 🔑 License 140 | Chameleon is released and distributed under the terms and conditions of the [MIT license](https://github.com/ViccAlexander/Chameleon/blob/master/LICENSE.md). 141 | 142 | ## 👥 Contributions 143 | 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. 144 | 145 | If you use Chameleon in your app we would love to hear about it! Drop Vicc a line on [twitter](http://twitter.com/viccsmind). 146 | 147 | ## 📗 Documentation 148 | All methods, properties, and types available in Chameleon are documented below. 149 | 150 | ##### Documentation Table of Contents 151 | [● Installation](https://github.com/ViccAlexander/Chameleon#installation) 152 | [● Palettes](https://github.com/ViccAlexander/Chameleon#palettes) 153 | [● Usage](https://github.com/ViccAlexander/Chameleon#usage) 154 | [● UIColor Methods](https://github.com/ViccAlexander/Chameleon#uicolor-methods) 155 | [● Colors From Images](https://github.com/ViccAlexander/Chameleon#colors-from-images) 156 | [● UIStatusBarStyle Methods](https://github.com/ViccAlexander/Chameleon#uistatusbarstyle-methods) 157 | [● Color Scheme Methods](https://github.com/ViccAlexander/Chameleon#color-schemes-methods) 158 | [● Theme Methods](https://github.com/ViccAlexander/Chameleon#theme-methods) 159 | 160 | ### Installation 161 | 162 | ###### Note: Swift 3 version maintained in a separate branch until it's release. 163 | 164 | #### CocoaPods Installation 165 | Chameleon is now available on [CocoaPods](http://cocoapods.org). Simply add the following to your project Podfile, and you'll be good to go. 166 | 167 | ###### Objective-C 168 | ```ruby 169 | use_frameworks! 170 | 171 | pod 'ChameleonFramework' 172 | ``` 173 | ###### Swift 174 | ```ruby 175 | use_frameworks! 176 | 177 | pod 'ChameleonFramework/Swift' 178 | ``` 179 | 180 | ======= 181 | #### Carthage Installation 182 | Add this to your Cartfile: 183 | ```ruby 184 | github "ViccAlexander/Chameleon" 185 | ``` 186 | 187 | ======= 188 | #### Manual Installation 189 | 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! 190 | 191 |

192 | Manual Installation 193 |

194 | 195 | 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. 196 | 197 | #### Palettes 198 | ##### Storyboard Add-On 199 | 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). 200 | 201 | Once installed, make sure to restart Xcode. You'll find all of Chameleon's colors in the Palette Color Picker whenever they're needed! :) 202 | 203 |

204 | Chameleon Palette 205 |

206 | 207 |

208 | Chameleon Palette 209 |

210 | 211 | ##### Photoshop Add-On 212 | 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). 213 | 214 | ##### Sketch Add-On 215 | 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). 216 | 217 | ### Usage 218 | To use the myriad of features in Chameleon, include the following import: 219 | 220 | ###### If you installed Chameleon using CocoaPods: 221 | 222 | ###### Objective-C 223 | 224 | ``` objective-c 225 | #import 226 | ``` 227 | 228 | ###### Swift: 229 | ``` swift 230 | import ChameleonFramework 231 | ``` 232 | 233 | ###### If you installed Chameleon using Carthage: 234 | 235 | ``` swift 236 | import Chameleon 237 | ``` 238 | 239 | ###### If you installed Chameleon manually: 240 | ``` objective-c 241 | #import "Chameleon.h" 242 | ``` 243 | ### UIColor Methods 244 | [● Flat Colors](https://github.com/ViccAlexander/Chameleon#flat-colors) 245 | [● Random Colors](https://github.com/ViccAlexander/Chameleon#random-colors) 246 | [● Complementary Colors](https://github.com/ViccAlexander/Chameleon#complementary-colors) 247 | [● Contrasting Colors](https://github.com/ViccAlexander/Chameleon#contrasting-colors) 248 | [● Flattening Non-Flat Colors](https://github.com/ViccAlexander/Chameleon#flattening-non-flat-colors) 249 | [● Gradient Colors](https://github.com/ViccAlexander/Chameleon#gradient-colors-1) 250 | [● Hex Colors](https://github.com/ViccAlexander/Chameleon#hex-colors-) 251 | [● Lighter & Darker Colors](https://github.com/ViccAlexander/Chameleon#lighter-and-darker-colors-) 252 | 253 | #### Flat Colors 254 | 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: 255 | 256 | ##### Normal Convention: 257 | 258 | ###### Objective-C 259 | ``` objective-c 260 | self.view.backgroundColor = [UIColor flatGreenColorDark]; 261 | ``` 262 | ###### Swift 263 | ``` swift 264 | view.backgroundColor = UIColor.flatGreenDark 265 | ``` 266 | 267 | ##### Chameleon Shorthand: 268 | 269 | ###### Objective-C 270 | ``` objective-c 271 | self.view.backgroundColor = FlatGreenDark; 272 | ``` 273 | ###### Swift 274 | ``` swift 275 | view.backgroundColor = FlatGreenDark() 276 | ``` 277 | 278 | 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: 279 | 280 | ##### Normal Convention: 281 | ###### Objective-C 282 | ``` objective-c 283 | self.view.backgroundColor = [UIColor flatGreenColor]; 284 | ``` 285 | ###### Swift 286 | ``` swift 287 | view.backgroundColor = UIColor.flatGreen 288 | ``` 289 | 290 | ##### Chameleon Shorthand: 291 | 292 | ###### Objective-C 293 | ``` objective-c 294 | self.view.backgroundColor = FlatGreen; 295 | ``` 296 | ###### Swift 297 | ``` swift 298 | view.backgroundColor = FlatGreen() 299 | ``` 300 | 301 | #### Random Colors 302 | 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: 303 | 304 | ##### Normal Convention: 305 | ###### Objective-C 306 | ``` objective-c 307 | self.view.backgroundColor = [UIColor randomFlatColor]; 308 | ``` 309 | ###### Swift 310 | ``` swift 311 | view.backgroundColor = UIColor.randomFlat 312 | ``` 313 | 314 | ##### Chameleon Shorthand: 315 | ###### Objective-C 316 | ``` objective-c 317 | self.view.backgroundColor = RandomFlatColor; 318 | ``` 319 | 320 | ###### Swift 321 | ``` swift 322 | view.backgroundColor = RandomFlatColor() 323 | ``` 324 | 325 | Otherwise, you can perform the following method call to specify whether it should return either a light or dark shade: 326 | 327 | ##### Normal Convention: 328 | ###### Objective-C 329 | ``` objective-c 330 | [UIColor colorWithRandomFlatColorOfShadeStyle:UIShadeStyleLight]; 331 | ``` 332 | 333 | ###### Swift 334 | ``` swift 335 | UIColor(randomFlatColorOfShadeStyle:.Light) 336 | ``` 337 | 338 | ##### Chameleon Shorthand: 339 | ###### Objective-C 340 | ``` objective-c 341 | RandomFlatColorWithShade(UIShadeStyleLight); 342 | ``` 343 | ###### Swift 344 | ``` swift 345 | RandomFlatColorWithShade(.Light) 346 | ``` 347 | 348 | **UIShadeStyles:** 349 | - `UIShadeStyleLight` (`UIShadeStyle.Light` in Swift) 350 | - `UIShadeStyleDark` (`UIShadeStyle.Dark` in Swift) 351 | 352 | ##### Choosing A Random Color From a List of Colors ![New](http://i.imgur.com/BX3b9ES.png) 353 | 354 | 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: 355 | 356 | ##### Normal Convention: 357 | ###### Objective-C 358 | ``` objective-c 359 | [UIColor colorWithRandomColorInArray:@[FlatWhite, FlatRed, FlatBlue]]; 360 | ``` 361 | 362 | ###### Swift 363 | ``` swift 364 | TBA 365 | ``` 366 | 367 | ##### Chameleon Shorthand: 368 | ###### Objective-C 369 | ``` objective-c 370 | RandomFlatColorInArray(@[FlatWhite, FlatRed, FlatBlue]) 371 | ``` 372 | ###### Swift 373 | ``` swift 374 | TBA 375 | ``` 376 | 377 | ##### Choosing A Random Flat Color But Excluding A Few ![New](http://i.imgur.com/BX3b9ES.png) 378 | 379 | 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: 380 | 381 | ##### Normal Convention: 382 | ###### Objective-C 383 | ``` objective-c 384 | [UIColor colorWithRandomFlatColorExcludingColorsInArray:@[FlatBlack, FlatBlackDark, FlatGray, FlatGrayDark, FlatWhite, FlatWhiteDark]]; 385 | ``` 386 | 387 | ###### Swift 388 | ``` swift 389 | TBA 390 | ``` 391 | 392 | ##### Chameleon Shorthand: 393 | ###### Objective-C 394 | ``` objective-c 395 | RandomFlatColorExcluding(@[FlatBlack, FlatBlackDark, FlatGray, FlatGrayDark, FlatWhite, FlatWhiteDark]) 396 | ``` 397 | ###### Swift 398 | ``` swift 399 | TBA 400 | ``` 401 | 402 | #### Complementary Colors 403 | To generate a complementary color, perform the following method call, remembering to specify the color whose complement you want: 404 | 405 | ##### Normal Convention: 406 | ###### Objective-C 407 | ``` objective-c 408 | [UIColor colorWithComplementaryFlatColorOf:(UIColor *)someUIColor]; 409 | ``` 410 | 411 | ###### Swift 412 | ``` swift 413 | UIColor(complementaryFlatColorOf:someUIColor) 414 | ``` 415 | 416 | ##### Chameleon Shorthand: 417 | ###### Objective-C 418 | ``` objective-c 419 | ComplementaryFlatColorOf(color); 420 | ``` 421 | 422 | ###### Swift 423 | ``` swift 424 | ComplementaryFlatColorOf(color) 425 | ``` 426 | 427 | #### Contrasting Colors 428 | 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]`).* 429 | 430 | 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`. 431 | 432 | Here's an example: 433 | 434 | ##### Normal Convention: 435 | ###### Objective-C 436 | ``` objective-c 437 | [UIColor colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat]; 438 | ``` 439 | 440 | ###### Swift 441 | ``` swift 442 | UIColor(contrastingBlackOrWhiteColorOn:UIColor!, isFlat:Bool) 443 | ``` 444 | 445 | ##### Chameleon Shorthand: 446 | ###### Objective-C 447 | ``` objective-c 448 | ContrastColor(backgroundColor, isFlat); 449 | ``` 450 | 451 | ###### Swift 452 | ``` swift 453 | ContrastColor(backgroundColor, isFlat) 454 | ``` 455 | 456 | #### Flattening Non-Flat Colors 457 | 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: 458 | 459 | ##### Normal Convention: 460 | ###### Objective-C 461 | ``` objective-c 462 | [(UIColor *)color flatten]; 463 | ``` 464 | 465 | ###### Swift 466 | ``` swift 467 | UIColor.pink.flatten() 468 | ``` 469 | 470 | #### Gradient Colors 471 | 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! 472 | 473 | ##### Gradient Styles 474 | 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! 475 | 476 | **UIGradientStyles:** 477 | * `UIGradientStyleLeftToRight` (UIGradientStyle.LeftToRight in Swift) 478 | * `UIGradientStyleTopToBottom` (UIGradientStyle.TopToBottom in Swift) 479 | * `UIGradientStyleRadial` (UIGradientStyle.Radial in Swift) 480 | 481 | ##### Normal Convention: 482 | ###### Objective-C 483 | ``` objective-c 484 | [UIColor colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray *)colors]; 485 | ``` 486 | 487 | ###### Swift 488 | ``` swift 489 | UIColor(gradientStyle:UIGradientStyle, withFrame:CGRect, andColors:[UIColor]) 490 | ``` 491 | 492 | ##### Chameleon Shorthand: 493 | ###### Objective-C 494 | ``` objective-c 495 | GradientColor(gradientStyle, frame, colors); 496 | ``` 497 | 498 | ###### Swift 499 | ``` swift 500 | GradientColor(gradientStyle, frame, colors) 501 | ``` 502 | 503 | **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. 504 | 505 | Note: `UIGradientStyleRadial` only uses a maximum of 2 colors at the moment. So if more colors are provided, they will not show. 506 | 507 | #### Hex Colors 508 | 509 | One of the most requested features, *hex colors*, is now available. You can simply provide a hex string with or without a *#* sign: 510 | 511 | ##### Normal Convention: 512 | ###### Objective-C 513 | ``` objective-c 514 | [UIColor colorWithHexString:(NSString *)string]; 515 | ``` 516 | 517 | ###### Swift 518 | ``` swift 519 | UIColor(hexString:string) 520 | ``` 521 | 522 | ##### Chameleon Shorthand: 523 | ###### Objective-C 524 | ``` objective-c 525 | HexColor(hexString) 526 | ``` 527 | 528 | ###### Swift 529 | ``` swift 530 | HexColor(hexString) 531 | ``` 532 | #### Hex Values ![New](http://i.imgur.com/BX3b9ES.png) 533 | 534 | Retrieving the `hexValue` of a UIColor is just as easy. 535 | 536 | ###### Objective-C 537 | ``` objective-c 538 | [FlatGreen hexValue]; //Returns @"2ecc71" 539 | ``` 540 | 541 | ###### Swift 542 | ``` swift 543 | FlatGreen.hexValue //Returns @"2ecc71" 544 | ``` 545 | 546 | #### Lighter and Darker Colors 547 | 548 | 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: 549 | 550 | ##### Normal Convention: 551 | ###### Objective-C 552 | ``` objective-c 553 | [color lightenByPercentage:(CGFloat)percentage]; 554 | ``` 555 | 556 | ###### Swift 557 | ``` swift 558 | color.lightenByPercentage(percentage: CGFloat) 559 | ``` 560 | 561 | You can also generate a darker version of a color: 562 | 563 | ##### Normal Convention: 564 | ###### Objective-C 565 | ``` objective-c 566 | [color darkenByPercentage:(CGFloat)percentage]; 567 | ``` 568 | 569 | ###### Swift 570 | ``` swift 571 | color.darkenByPercentage(percentage: CGFloat) 572 | ``` 573 | 574 | ### Colors From Images 575 | 576 | 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. 577 | 578 | To generate a color scheme simply do the following: 579 | ##### Normal Convention: 580 | ###### Objective-C 581 | ``` objective-c 582 | [NSArray arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)flatScheme]; 583 | ``` 584 | 585 | ###### Swift (**Array extension missing**) 586 | ``` swift 587 | NSArray(ofColorsFromImage: UIImage, withFlatScheme: Bool) 588 | ``` 589 | 590 | ##### Chameleon Shorthand: 591 | ###### Objective-C 592 | ``` objective-c 593 | ColorsFromImage(image, isFlatScheme) 594 | ``` 595 | 596 | ###### Swift 597 | ``` swift 598 | ColorsFromImage(image, isFlatScheme) 599 | ``` 600 | 601 | To extract the average color from an image, you can also do: 602 | ##### Normal Convention: 603 | ###### Objective-C 604 | ``` objective-c 605 | [UIColor colorWithAverageColorFromImage:(UIImage *)image]; 606 | ``` 607 | 608 | ###### Swift 609 | ``` swift 610 | UIColor(averageColorFromImage: UIImage) 611 | ``` 612 | 613 | ##### Chameleon Shorthand: 614 | ###### Objective-C 615 | ``` objective-c 616 | AverageColorFromImage(image) 617 | ``` 618 | 619 | ###### Swift 620 | ``` swift 621 | AverageColorFromImage(image) 622 | ``` 623 | 624 | ### UIStatusBarStyle Methods 625 | #### Contrasting UIStatusBarStyle 626 | 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: 627 | 628 | ##### Normal Convention: 629 | ###### Objective-C 630 | ``` objective-c 631 | [self setStatusBarStyle:UIStatusBarStyleContrast]; 632 | ``` 633 | 634 | ###### Swift 635 | ``` swift 636 | self.setStatusBarStyle(UIStatusBarStyleContrast) 637 | ``` 638 | ###### **Note**: Make sure that the key *View controller-based status bar appearance* in **Info.plist** is set to `YES`. 639 | 640 | ### Color Schemes Methods 641 | ###### **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.* 642 | 643 | 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. 644 | 645 | #### Analogous Color Scheme 646 | 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. 647 | 648 | #### Complementary Color Scheme 649 | 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. 650 | 651 | #### Triadic Color Scheme 652 | 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. 653 | 654 | #### Getting Colors in a Color Scheme 655 | 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): 656 | 657 | ##### Normal Convention: 658 | ###### Objective-C 659 | ``` objective-c 660 | NSMutableArray *colorArray = [NSMutableArray alloc] initWithArray:[NSArray arrayOfColorsWithColorScheme:(ColorScheme)colorScheme 661 | with:(UIColor *)color 662 | flatScheme:(BOOL)isFlatScheme]]; 663 | ``` 664 | 665 | ###### Swift 666 | ``` swift 667 | var colorArray = NSArray(ofColorsWithColorScheme:ColorScheme, with:UIColor!, flatScheme:Bool) 668 | ``` 669 | 670 | ##### Chameleon Shorthand: 671 | ###### Objective-C 672 | ``` objective-c 673 | NSMutableArray *colorArray = [[NSMutableArray alloc] initWithArray:ColorScheme(colorSchemeType, color, isFlatScheme)]; 674 | ``` 675 | 676 | ###### Swift 677 | ``` swift 678 | var colorArray = ColorSchemeOf(colorSchemeType, color, isFlatScheme) 679 | ``` 680 | 681 | ##### Example: 682 | Assuming you want to generate an analogous color scheme for the light shade of Flat Red, perform the following method call: 683 | 684 | ##### Normal Convention: 685 | ###### Objective-C 686 | ``` objective-c 687 | NSMutableArray *colorArray = [NSMutableArray alloc] initWithArray:[NSArray arrayOfColorsWithColorScheme:ColorSchemeAnalogous 688 | with:[UIColor flatRedColor] 689 | flatScheme:YES]]; 690 | ``` 691 | 692 | ###### Swift 693 | ``` swift 694 | var colorArray = NSArray(ofColorsWithColorScheme:ColorScheme.Analogous, with:UIColor.flatRed, flatScheme:true) 695 | ``` 696 | 697 | ##### Chameleon Shorthand: 698 | ###### Objective-C 699 | ``` objective-c 700 | NSMutableArray *colorArray = [[NSMutableArray alloc] initWithArray:ColorScheme(ColorSchemeAnalogous, FlatRed, YES)]; 701 | ``` 702 | 703 | ###### Swift 704 | ``` swift 705 | var colorArray = ColorSchemeOf(ColorScheme.Analogous, FlatRed(), true) 706 | ``` 707 | 708 | You can then retrieve each individual color the same way you would normally retrieve any object from an array: 709 | 710 | ###### Objective-C 711 | ```objective-c 712 | UIColor *firstColor = colorArray[0]; 713 | ``` 714 | 715 | ###### Swift 716 | ``` swift 717 | var firstColor = colorArray[0] as! UIColor 718 | ``` 719 | 720 | ### Theme Methods 721 | 722 | 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`. 723 | 724 | To set a global theme, you can do the following in your app delegate: 725 | 726 | ##### Normal Convention: 727 | ###### Objective-C 728 | ``` objective-c 729 | [Chameleon setGlobalThemeUsingPrimaryColor:(UIColor *)color withContentStyle:(UIContentStyle)contentStyle]; 730 | ``` 731 | 732 | 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: 733 | 734 | ##### Normal Convention: 735 | ###### Objective-C 736 | ```objective-c 737 | //This would go in the controller you specifically want to theme differently 738 | [self setThemeUsingPrimaryColor:FlatMint withSecondaryColor:FlatBlue andContentStyle:UIContentStyleContrast]; 739 | ``` 740 | 741 | ###### **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`. 742 | 743 | #### Navigation Bar Hairline 744 | 745 | ![No Hairline](http://i.imgur.com/tjwx53y.png) 746 | 747 | 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: 748 | 749 | ###### Objective-C 750 | ```objective-c 751 | [self.navigationController setHidesNavigationBarHairline:YES]; 752 | 753 | //or 754 | 755 | self.navigationController.hidesNavigationBarHairline = YES; 756 | ``` 757 | 758 | ###### Swift 759 | ```swift 760 | self.navigationController?.hidesNavigationBarHairline = true 761 | ``` 762 | 763 | ## 👑 Author 764 | 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). 765 | 766 | ## 📝 To Do List 767 | * ~~CocoaPods Support~~ ![1.0.1](http://i.imgur.com/8Li5aRR.png) 768 | * ~~Table of Contents~~ ![1.0.1](http://i.imgur.com/8Li5aRR.png) 769 | * ~~Storyboard Color Picker Add-On~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) 770 | * ~~Xcode In-App Documentation~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) 771 | * ~~Switch from RGB values over to HSB and LAB~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) 772 | * ~~Gradient Colors~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) 773 | * ~~Update GradientStyle & ShadeStyle Syntax~~ ![1.1.1](http://i.imgur.com/AHxj8Rb.png) 774 | * ~~Add Radial Gradient Support~~ ![1.1.1](http://i.imgur.com/AHxj8Rb.png) 775 | * ~~Fix Swift Conflict with `initWithArray:for:flatScheme:` method~~ ![1.1.12](http://i.imgur.com/7NrZ7yx.png) 776 | * ~~Swift Support~~ ![1.1.3](http://i.imgur.com/WgpBlLo.png) 777 | * ~~Color Scheme From Images~~ ![2.0.0](http://i.imgur.com/HdE8kjQ.png) 778 | * ~~UIAppearance Convenience Methods~~ ![2.0.0](http://i.imgur.com/HdE8kjQ.png) 779 | * ~~Add option to hide `NavigationBar` hairline~~ ![2.0.3](http://i.imgur.com/DmlOKPJ.png) 780 | * ~~Add support for App Extensions hairline~~ ![2.2.0](http://i.imgur.com/z6575IT.png) 781 | * Add Swift Support for Random Colors 782 | * Allow Gradient Colors to Adapt To Frame Changes 783 | 784 | ## 📄 Change Log 785 | 786 | ### See [Changelog.md](https://github.com/ViccAlexander/Chameleon/blob/master/CHANGELOG.md) 👀 787 | 788 | --------------------------------------------------------------------------------