Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
2.0.5 Release
Browse files Browse the repository at this point in the history
• Added Theme Support to UIImagePickerController Class.
• Fixed If-Else Statement Syntax Bug in isDistinctColor method
  • Loading branch information
vicc committed Nov 26, 2015
1 parent 45ee583 commit e02a817
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 54 deletions.
4 changes: 2 additions & 2 deletions ChameleonFramework.podspec
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 }

Expand Down
129 changes: 79 additions & 50 deletions Pod/Classes/Objective-C/Chameleon_.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -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];
Expand All @@ -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) {

Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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];
}
}

Expand Down Expand Up @@ -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];

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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] }];
Expand Down Expand Up @@ -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];
}
}

Expand Down
4 changes: 2 additions & 2 deletions Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e02a817

Please sign in to comment.