From acec14309fb15ad6c1d57f2208a486bcb0ea9309 Mon Sep 17 00:00:00 2001 From: Vicc Alexander Date: Fri, 2 Oct 2015 05:15:53 -0700 Subject: [PATCH] Updated to 2.0.3 * Added `HidesNavigationBarHairline` boolean, and by default it is now set to `NO`. * Edited Quick Look Documentation for several methods. --- ChameleonDemo/Base.lproj/Main.storyboard | 6 +-- ChameleonFramework.podspec | 2 +- Pod/Classes/Objective-C/Chameleon_.h | 6 +-- .../UINavigationController+Chameleon.h | 7 +++ .../UINavigationController+Chameleon.m | 48 +++++++++++++++++-- .../Objective-C/UIViewController+Chameleon.h | 6 +-- 6 files changed, 61 insertions(+), 14 deletions(-) diff --git a/ChameleonDemo/Base.lproj/Main.storyboard b/ChameleonDemo/Base.lproj/Main.storyboard index 2ad4070..aeadfff 100644 --- a/ChameleonDemo/Base.lproj/Main.storyboard +++ b/ChameleonDemo/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -78,7 +78,7 @@ - + diff --git a/ChameleonFramework.podspec b/ChameleonFramework.podspec index a5eab13..62542d7 100755 --- a/ChameleonFramework.podspec +++ b/ChameleonFramework.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "ChameleonFramework" - s.version = "2.0.2.2" + s.version = "2.0.3" s.summary = "Color Framework for iOS (Obj-C & Swift)" s.homepage = "https://github.com/ViccAlexander/Chameleon" s.screenshots = "https://camo.githubusercontent.com/bde5aa6ee0e1feec044d184a735da8024c60c04c/687474703a2f2f692e696d6775722e636f6d2f427771486842342e706e67" diff --git a/Pod/Classes/Objective-C/Chameleon_.h b/Pod/Classes/Objective-C/Chameleon_.h index d78737a..d492a47 100644 --- a/Pod/Classes/Objective-C/Chameleon_.h +++ b/Pod/Classes/Objective-C/Chameleon_.h @@ -23,7 +23,7 @@ #pragma mark - Global Theming /** - * Set a global theme using a primary color. + * Set a global theme using a primary color and the specified content style. * * @param primaryColor The primary color to theme all controllers with. * @param contentStyle The contentStyle. @@ -36,7 +36,7 @@ withContentStyle:(UIContentStyle)contentStyle; /** - * Set a global theme using a primary color. + * Set a global theme using a primary color, secondary color, and the specified content style. * * @param primaryColor The primary color to theme all controllers with. * @param secondaryColor The secondary color to theme all controllers with. @@ -49,7 +49,7 @@ andContentStyle:(UIContentStyle)contentStyle; /** - * Set a global theme using a primary color. + * Set a global theme using a primary color, secondary color, font name, and the specified content style. * * @param primaryColor The primary color to theme all controllers with. * @param secondaryColor The secondary color to theme all controllers with. diff --git a/Pod/Classes/Objective-C/UINavigationController+Chameleon.h b/Pod/Classes/Objective-C/UINavigationController+Chameleon.h index 1ec0c02..6913d49 100644 --- a/Pod/Classes/Objective-C/UINavigationController+Chameleon.h +++ b/Pod/Classes/Objective-C/UINavigationController+Chameleon.h @@ -22,4 +22,11 @@ */ - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; +/** + * Hides the hairline view at the bottom of a navigation bar. The default value is @c NO. + * + * @since 2.0.3 + */ +@property (nonatomic, assign) BOOL hidesNavigationBarHairline; + @end diff --git a/Pod/Classes/Objective-C/UINavigationController+Chameleon.m b/Pod/Classes/Objective-C/UINavigationController+Chameleon.m index ee086c9..1599815 100644 --- a/Pod/Classes/Objective-C/UINavigationController+Chameleon.m +++ b/Pod/Classes/Objective-C/UINavigationController+Chameleon.m @@ -26,6 +26,8 @@ @interface UINavigationController () @implementation UINavigationController (Chameleon) +@dynamic hidesNavigationBarHairline; + #pragma mark - Swizzling + (void)load { @@ -60,24 +62,35 @@ + (void)load { } - (void)chameleon_viewDidLoad { + [self chameleon_viewDidLoad]; - UIView *heairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; - if (heairlineImageView) { - heairlineImageView.hidden = YES; + UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; + + if (hairlineImageView) { + + if (self.hidesNavigationBarHairline) { + hairlineImageView.hidden = YES; + + } else { + hairlineImageView.hidden = NO; + } } } - (UIImageView *)findHairlineImageViewUnder:(UIView *)view { + if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) { return (UIImageView *)view; } + for (UIView *subview in view.subviews) { UIImageView *imageView = [self findHairlineImageViewUnder:subview]; if (imageView) { return imageView; } } + return nil; } @@ -107,6 +120,34 @@ - (BOOL)shouldUseLightContent { return [number boolValue]; } +- (void)setHidesNavigationBarHairline:(BOOL)hidesNavigationBarHairline { + + NSNumber *number = [NSNumber numberWithBool:hidesNavigationBarHairline]; + objc_setAssociatedObject(self, @selector(hidesNavigationBarHairline), number, OBJC_ASSOCIATION_RETAIN); + + //Find Hairline Image + UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; + + //Check if it exists + if (hairlineImageView) { + + //Check if we should hide it or not + if (hidesNavigationBarHairline) { + hairlineImageView.hidden = YES; + + } else { + hairlineImageView.hidden = NO; + } + } +} + +- (BOOL)hidesNavigationBarHairline { + + NSNumber *number = objc_getAssociatedObject(self, @selector(hidesNavigationBarHairline)); + return [number boolValue]; +} + + #pragma mark - Public Methods - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { @@ -129,7 +170,6 @@ - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { } } - #pragma mark - Private Methods - (UIStatusBarStyle)preferredStatusBarStyle { diff --git a/Pod/Classes/Objective-C/UIViewController+Chameleon.h b/Pod/Classes/Objective-C/UIViewController+Chameleon.h index 1e173b5..f84b945 100644 --- a/Pod/Classes/Objective-C/UIViewController+Chameleon.h +++ b/Pod/Classes/Objective-C/UIViewController+Chameleon.h @@ -12,7 +12,7 @@ @interface UIViewController (Chameleon) /** - * Sets the color theme for the specified view controller. + * Sets the color theme for the specified view controller using a primary color and the specified content style. * * @param primaryColor The primary color. * @param contentStyle The contentStyle. @@ -23,7 +23,7 @@ withContentStyle:(UIContentStyle)contentStyle; /** - * Sets the color theme for the specified view controller. + * Sets the color theme for the specified view controller using a primary color, secondary color, and the specified content style. * * @param primaryColor The primary color. * @param secondaryColor The secondary color. @@ -36,7 +36,7 @@ andContentStyle:(UIContentStyle)contentStyle; /** - * Sets the color theme for the specified view controller. + * Sets the color theme for the specified view controller using a primary color, secondary color, font name, and the specified content style. * * @param primaryColor The primary color. * @param secondaryColor The secondary color.