From 0a1b8c618c85c3aa4c0bb1b19447ee5537de09a5 Mon Sep 17 00:00:00 2001 From: Jean-Charles SORIN Date: Fri, 10 Apr 2015 14:43:31 +0200 Subject: [PATCH] Specify an opaque background for or FrostedContainer --- .../REFrostedContainerViewController.m | 1 + REFrostedViewController/REFrostedViewController.h | 1 + REFrostedViewController/REFrostedViewController.m | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/REFrostedViewController/REFrostedContainerViewController.m b/REFrostedViewController/REFrostedContainerViewController.m index 6830fb8..0b248fc 100644 --- a/REFrostedViewController/REFrostedContainerViewController.m +++ b/REFrostedViewController/REFrostedContainerViewController.m @@ -74,6 +74,7 @@ - (void)viewDidLoad [self.containerView addSubview:toolbar]; } else { self.backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; + self.containerView.backgroundColor = self.frostedViewController.backgroundContainerColor; [self.containerView addSubview:self.backgroundImageView]; } diff --git a/REFrostedViewController/REFrostedViewController.h b/REFrostedViewController/REFrostedViewController.h index e01ffa8..58de21a 100644 --- a/REFrostedViewController/REFrostedViewController.h +++ b/REFrostedViewController/REFrostedViewController.h @@ -54,6 +54,7 @@ typedef NS_ENUM(NSInteger, REFrostedViewControllerLiveBackgroundStyle) { * The default value is 0.3. */ @property (assign, readwrite, nonatomic) CGFloat backgroundFadeAmount; +@property (assign, readwrite, nonatomic) UIColor *backgroundContainerColor;//take the priority insteed of liveBlur, if we want a specific opaque background @property (strong, readwrite, nonatomic) UIColor *blurTintColor; // Used only when live blur is off @property (assign, readwrite, nonatomic) CGFloat blurRadius; // Used only when live blur is off @property (assign, readwrite, nonatomic) CGFloat blurSaturationDeltaFactor; // Used only when live blur is off diff --git a/REFrostedViewController/REFrostedViewController.m b/REFrostedViewController/REFrostedViewController.m index 3087448..d3e4562 100644 --- a/REFrostedViewController/REFrostedViewController.m +++ b/REFrostedViewController/REFrostedViewController.m @@ -78,7 +78,7 @@ - (void)commonInit _containerViewController = [[REFrostedContainerViewController alloc] init]; _containerViewController.frostedViewController = self; _menuViewSize = CGSizeZero; - _liveBlur = REUIKitIsFlatMode(); + _liveBlur = NO; _panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:_containerViewController action:@selector(panGestureRecognized:)]; _automaticSize = YES; } @@ -189,7 +189,7 @@ - (void)presentMenuViewControllerWithAnimatedApperance:(BOOL)animateApperance _menuViewSize.height > 0 ? _menuViewSize.height : self.contentViewController.view.frame.size.height); } - if (!self.liveBlur) { + if (self.liveBlur && !self.backgroundContainerColor) { if (REUIKitIsFlatMode() && !self.blurTintColor) { self.blurTintColor = [UIColor colorWithWhite:1 alpha:0.75f]; } @@ -205,7 +205,7 @@ - (void)hideMenuViewControllerWithCompletionHandler:(void(^)(void))completionHan if (!self.visible) {//when call hide menu before menuViewController added to containerViewController, the menuViewController will never added to containerViewController return; } - if (!self.liveBlur) { + if (self.liveBlur && !self.frostedViewController.backgroundContainerColor) { self.containerViewController.screenshotImage = [[self.contentViewController.view re_screenshot] re_applyBlurWithRadius:self.blurRadius tintColor:self.blurTintColor saturationDeltaFactor:self.blurSaturationDeltaFactor maskImage:nil]; [self.containerViewController refreshBackgroundImage]; } @@ -214,7 +214,7 @@ - (void)hideMenuViewControllerWithCompletionHandler:(void(^)(void))completionHan - (void)resizeMenuViewControllerToSize:(CGSize)size { - if (!self.liveBlur) { + if (self.liveBlur && !self.frostedViewController.backgroundContainerColor) { self.containerViewController.screenshotImage = [[self.contentViewController.view re_screenshot] re_applyBlurWithRadius:self.blurRadius tintColor:self.blurTintColor saturationDeltaFactor:self.blurSaturationDeltaFactor maskImage:nil]; [self.containerViewController refreshBackgroundImage]; }