From df91af615b6702aa9d5a60738e388eab86c55bb1 Mon Sep 17 00:00:00 2001 From: Danny Sung Date: Fri, 8 Aug 2014 16:28:17 -0700 Subject: [PATCH 1/2] Added property "overlayEnabled" to allow for disabling of overlays --- WYPopoverController/WYPopoverController.h | 2 +- WYPopoverController/WYPopoverController.m | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WYPopoverController/WYPopoverController.h b/WYPopoverController/WYPopoverController.h index 25f23381..62143eb1 100644 --- a/WYPopoverController/WYPopoverController.h +++ b/WYPopoverController/WYPopoverController.h @@ -102,7 +102,7 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) { @property (nonatomic, strong, readonly) UIViewController *contentViewController; @property (nonatomic, assign) CGSize popoverContentSize; @property (nonatomic, assign) float animationDuration; - +@property (nonatomic, assign, getter = isOverlayEnabled) BOOL overlayEnabled; @property (nonatomic, strong) WYPopoverTheme *theme; + (void)setDefaultTheme:(WYPopoverTheme *)theme; diff --git a/WYPopoverController/WYPopoverController.m b/WYPopoverController/WYPopoverController.m index 34ea4862..2e61b747 100644 --- a/WYPopoverController/WYPopoverController.m +++ b/WYPopoverController/WYPopoverController.m @@ -1684,6 +1684,7 @@ - (id)init themeUpdatesEnabled = YES; popoverContentSize_ = CGSizeZero; + self.overlayEnabled = YES; } return self; @@ -1935,7 +1936,9 @@ - (void)presentPopoverFromRect:(CGRect)aRect backgroundView.hidden = YES; [inView.window addSubview:backgroundView]; - [inView.window insertSubview:overlayView belowSubview:backgroundView]; + if( self.isOverlayEnabled ) { + [inView.window insertSubview:overlayView belowSubview:backgroundView]; + } } [self updateThemeUI]; From 32df312cf6f431e271ecdec30ccf60888ab84480 Mon Sep 17 00:00:00 2001 From: Danny Sung Date: Fri, 8 Aug 2014 16:36:51 -0700 Subject: [PATCH 2/2] Created a new theme property visibleAlpha, allowing the visible alpha state to be something other than 1.0f --- WYPopoverController/WYPopoverController.h | 2 +- WYPopoverController/WYPopoverController.m | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/WYPopoverController/WYPopoverController.h b/WYPopoverController/WYPopoverController.h index 62143eb1..93eecc27 100644 --- a/WYPopoverController/WYPopoverController.h +++ b/WYPopoverController/WYPopoverController.h @@ -86,7 +86,6 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) { @property (nonatomic, assign) UIEdgeInsets viewContentInsets UI_APPEARANCE_SELECTOR; @property (nonatomic, strong) UIColor *overlayColor UI_APPEARANCE_SELECTOR; - @end //////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -246,6 +245,7 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) { @property (nonatomic, assign) UIEdgeInsets viewContentInsets; @property (nonatomic, strong) UIColor *overlayColor; +@property (nonatomic, readwrite) CGFloat visibleAlpha; + (instancetype)theme; + (instancetype)themeForIOS6; diff --git a/WYPopoverController/WYPopoverController.m b/WYPopoverController/WYPopoverController.m index 2e61b747..7402c5df 100644 --- a/WYPopoverController/WYPopoverController.m +++ b/WYPopoverController/WYPopoverController.m @@ -31,7 +31,7 @@ of this software and associated documentation files (the "Software"), to deal #define WY_BASE_SDK_7_ENABLED #endif -#ifdef DEBUG +#if defined(DEBUG) && !WYPOPOVER_NOLOG #define WY_LOG(fmt, ...) NSLog((@"%s (%d) : " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define WY_LOG(...) @@ -433,6 +433,7 @@ @implementation WYPopoverTheme @synthesize viewContentInsets; @synthesize overlayColor; +@synthesize visibleAlpha; + (id)theme { @@ -473,6 +474,7 @@ + (id)themeForIOS6 { result.innerCornerRadius = 6; result.viewContentInsets = UIEdgeInsetsMake(3, 0, 0, 0); result.overlayColor = [UIColor clearColor]; + result.visibleAlpha = 1.0f; return result; } @@ -503,7 +505,8 @@ + (id)themeForIOS7 { result.innerCornerRadius = 0; result.viewContentInsets = UIEdgeInsetsZero; result.overlayColor = [UIColor colorWithWhite:0 alpha:0.15]; - + result.visibleAlpha = 1.0f; + return result; } @@ -595,7 +598,8 @@ - (UIColor *)fillBottomColor } - (NSArray *)observableKeypaths { - return [NSArray arrayWithObjects:@"tintColor", @"outerStrokeColor", @"innerStrokeColor", @"fillTopColor", @"fillBottomColor", @"glossShadowColor", @"glossShadowOffset", @"glossShadowBlurRadius", @"borderWidth", @"arrowBase", @"arrowHeight", @"outerShadowColor", @"outerShadowBlurRadius", @"outerShadowOffset", @"outerCornerRadius", @"innerShadowColor", @"innerShadowBlurRadius", @"innerShadowOffset", @"innerCornerRadius", @"viewContentInsets", @"overlayColor", nil]; + return [NSArray arrayWithObjects:@"tintColor", @"outerStrokeColor", @"innerStrokeColor", @"fillTopColor", @"fillBottomColor", @"glossShadowColor", @"glossShadowOffset", @"glossShadowBlurRadius", @"borderWidth", @"arrowBase", @"arrowHeight", @"outerShadowColor", @"outerShadowBlurRadius", @"outerShadowOffset", @"outerCornerRadius", @"innerShadowColor", @"innerShadowBlurRadius", @"innerShadowOffset", @"innerCornerRadius", @"viewContentInsets", @"overlayColor", + @"visibleAlpha", nil]; } @end @@ -2017,8 +2021,8 @@ - (void)presentPopoverFromRect:(CGRect)aRect if (strongSelf) { - strongSelf->overlayView.alpha = 1; - strongSelf->backgroundView.alpha = 1; + strongSelf->overlayView.alpha = theme.visibleAlpha; + strongSelf->backgroundView.alpha = theme.visibleAlpha; strongSelf->backgroundView.transform = endTransform; } adjustTintDimmed(); @@ -2938,7 +2942,7 @@ - (CGSize)sizeForRect:(CGRect)aRect } #pragma mark Inline functions - +#if 0 static NSString* WYStringFromOrientation(NSInteger orientation) { NSString *result = @"Unknown"; @@ -2961,6 +2965,7 @@ - (CGSize)sizeForRect:(CGRect)aRect return result; } +#endif static float WYStatusBarHeight() { UIInterfaceOrientation orienation = [[UIApplication sharedApplication] statusBarOrientation];