From e02a817e3e4b0856681c8f342d42e8441fcc0ae9 Mon Sep 17 00:00:00 2001 From: Vicc Alexander Date: Thu, 26 Nov 2015 03:10:07 -0800 Subject: [PATCH] 2.0.5 Release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added Theme Support to UIImagePickerController Class. • Fixed If-Else Statement Syntax Bug in isDistinctColor method --- ChameleonFramework.podspec | 4 +- Pod/Classes/Objective-C/Chameleon_.m | 129 +++++++++++------- .../Objective-C/UIColor+ChameleonPrivate.m | 4 +- 3 files changed, 83 insertions(+), 54 deletions(-) diff --git a/ChameleonFramework.podspec b/ChameleonFramework.podspec index 62542d7..6d3fbe5 100755 --- a/ChameleonFramework.podspec +++ b/ChameleonFramework.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "ChameleonFramework" - s.version = "2.0.3" + s.version = "2.0.5" s.summary = "Color Framework for iOS (Obj-C & Swift)" s.homepage = "https://github.com/ViccAlexander/Chameleon" s.screenshots = "https://camo.githubusercontent.com/bde5aa6ee0e1feec044d184a735da8024c60c04c/687474703a2f2f692e696d6775722e636f6d2f427771486842342e706e67" @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.author = "Vicc Alexander" s.social_media_url = "http://twitter.com/ViccsMind" s.platform = :ios - s.ios.deployment_target = '7.0' + s.ios.deployment_target = '8.0' s.source = { :git => "https://github.com/ViccAlexander/Chameleon.git", :tag => s.version.to_s } diff --git a/Pod/Classes/Objective-C/Chameleon_.m b/Pod/Classes/Objective-C/Chameleon_.m index a37b1ed..6dba813 100644 --- a/Pod/Classes/Objective-C/Chameleon_.m +++ b/Pod/Classes/Objective-C/Chameleon_.m @@ -16,8 +16,8 @@ @implementation Chameleon #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor - withContentStyle:(UIContentStyle)contentStyle { - + withContentStyle:(UIContentStyle)contentStyle { + if (contentStyle == UIContentStyleContrast) { if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { @@ -34,7 +34,7 @@ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } - + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; [[self class] customizeButtonWithPrimaryColor:primaryColor withContentStyle:contentStyle]; [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; @@ -47,12 +47,13 @@ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor [[self class] customizeSwitchWithPrimaryColor:primaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor - withSecondaryColor:(UIColor *)secondaryColor - andContentStyle:(UIContentStyle)contentStyle { + withSecondaryColor:(UIColor *)secondaryColor + andContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { @@ -83,12 +84,13 @@ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; } + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor - withSecondaryColor:(UIColor *)secondaryColor - usingFontName:(NSString *)fontName - andContentStyle:(UIContentStyle)contentStyle { + withSecondaryColor:(UIColor *)secondaryColor + usingFontName:(NSString *)fontName + andContentStyle:(UIContentStyle)contentStyle { if (contentStyle == UIContentStyleContrast) { @@ -122,40 +124,40 @@ + (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; - + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; /* - if (contentStyle == UIContentStyleContrast) { - - if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; - } else { - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; - } - - } else if (contentStyle == UIContentStyleLight) { - - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; - - } else { - - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; - } - - [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; - [[self class] customizeButtonWithPrimaryColor:primaryColor fontName:fontName fontSize:17 contentStyle:contentStyle]; - [[self class] customizeLabelWithPrimaryColor:primaryColor fontName:fontName fontSize:18 withContentStyle:contentStyle]; - [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; - [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; - [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; - [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; - [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; - [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; - [[self class] customizeTabBarWithBarTintColor:FlatWhite tintColor:primaryColor fontName:fontName fontSize:11]; - [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; - - */ + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor fontName:fontName fontSize:17 contentStyle:contentStyle]; + [[self class] customizeLabelWithPrimaryColor:primaryColor fontName:fontName fontSize:18 withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite tintColor:primaryColor fontName:fontName fontSize:11]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + + */ } #pragma mark - UIBarButtonItem @@ -182,13 +184,13 @@ + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor break; } } - + [[UIBarButtonItem appearance] setTintColor:primaryColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; - + } + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor @@ -224,7 +226,7 @@ + (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor if ([UIFont fontWithName:fontName size:fontSize]) { [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{ NSForegroundColorAttributeName:contentColor, - NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize]} forState:UIControlStateNormal]; + NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize]} forState:UIControlStateNormal]; } } @@ -256,7 +258,6 @@ + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor [[UIButton appearance] setTintColor:contentColor]; [[UIButton appearance] setBackgroundColor:primaryColor]; - [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; @@ -270,9 +271,6 @@ + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; - - - } + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor @@ -320,9 +318,40 @@ + (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; +} + +#pragma mark - UIImagePickerController + ++ (void)customizeImagePickerControllerWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; } + #pragma mark - UILabel + (void)customizeLabelWithPrimaryColor:(UIColor *)primaryColor @@ -391,7 +420,7 @@ + (void)customizeNavigationBarWithPrimaryColor:(UIColor *)primaryColor [[UINavigationBar appearance] setTintColor:contentColor]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:contentColor}]; [[UINavigationBar appearance] setShadowImage:[UIImage new]]; -// [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; + // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor @@ -402,7 +431,7 @@ + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor [[UINavigationBar appearance] setTintColor:buttonColor]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:textColor}]; [[UINavigationBar appearance] setShadowImage:[UIImage new]]; -// [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; + // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; } + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor @@ -414,7 +443,7 @@ + (void)customizeNavigationBarWithBarColor:(UIColor *)barColor [[UINavigationBar appearance] setBarTintColor:barColor]; [[UINavigationBar appearance] setTintColor:buttonColor]; [[UINavigationBar appearance] setShadowImage:[UIImage new]]; -// [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; + // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; if ([UIFont fontWithName:fontName size:fontSize]) { [[UINavigationBar appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:textColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize] }]; @@ -594,7 +623,7 @@ + (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor UIFont *font = [UIFont fontWithName:fontName size:fontSize]; if (font) { [[UISegmentedControl appearance] setTitleTextAttributes:@{NSFontAttributeName:font} - forState:UIControlStateNormal]; + forState:UIControlStateNormal]; } } diff --git a/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m b/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m index cf4efc6..c5c7d47 100644 --- a/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m +++ b/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m @@ -100,12 +100,12 @@ - (BOOL)isDistinct:(UIColor *)color { fabs(b - bc) > threshold || fabs(a - ac) > threshold) { // Check for grays - if (abs(r - g < 0.03f && fabs(r - b) < 0.03f)) { + if (fabs(r - g) < 0.03f && fabs(r - b) < 0.03f) { if (fabs(rc - gc) < 0.03f && (fabs(rc - bc) < 0.03f)) { return NO; } - + } return YES;