diff --git a/README.md b/README.md index d902200..4789ec7 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,16 @@ Most of the customization options included within this component are related to By default, parallax and blur effects are enabled. To disable one or both effects, just set the following properties on your instance: - self.parallaxEnabled = NO; - self.shouldBlurBackground = NO; - -Note that currently if you disable the parallax effect, the background blur will also be disabled. + self.parallaxEnabled = NO; // default YES + self.shouldBlurBackground = NO; // default YES By default, tapping on the image will not dismiss the focus view (as controlled by `shouldDismissOnTap`), but tapping outside of the image bounds will. You can change this by setting `shouldDismissOnImageTap` to `YES` on your `URBMediaFocusViewController` instance, which will allow tapping directly on the image to dismiss: - self.shouldDismissOnImageTap = YES; + self.shouldDismissOnImageTap = YES; // default NO + +If you wish to only dismiss using UIDynamics, you can also dismiss the default tap gesture used to dismiss (not recommended for iOS 6 since UIDynamics isn't available): + + self.shouldDismissOnTap = NO; // default YES You can also provide copy and save actions for the presented photo from an action sheet when the image receives a long press gesture. By default this feature is disabled, so just control this using the `shouldShowPhotoActions` property: diff --git a/SampleProject/URBMediaFocusViewControllerDemo/DemoViewController.m b/SampleProject/URBMediaFocusViewControllerDemo/DemoViewController.m index 2b1356c..6f8e2e0 100644 --- a/SampleProject/URBMediaFocusViewControllerDemo/DemoViewController.m +++ b/SampleProject/URBMediaFocusViewControllerDemo/DemoViewController.m @@ -38,6 +38,8 @@ - (void)viewDidLoad { self.mediaFocusController = [[URBMediaFocusViewController alloc] init]; self.mediaFocusController.delegate = self; + //self.mediaFocusController.shouldBlurBackground = NO; // uncomment if you don't want the background blurred + //self.mediaFocusController.parallaxEnabled = NO; // uncomment if you don't want the parallax (push-back) effect //self.mediaFocusController.shouldDismissOnTap = NO; // uncomment if you wish to disable dismissing the view on a single tap outside image bounds //self.mediaFocusController.shouldDismissOnImageTap = YES; // uncomment if you wish to support dismissing view on a single tap on the image itself diff --git a/URBMediaFocusViewController.h b/URBMediaFocusViewController.h index 580906f..5741eba 100644 --- a/URBMediaFocusViewController.h +++ b/URBMediaFocusViewController.h @@ -50,7 +50,7 @@ @property (nonatomic, assign) BOOL shouldBlurBackground; @property (nonatomic, assign) BOOL parallaxEnabled; -// determines whether or not view should be dismissed when the container view is tapped anywhere, including outside image bounds +// determines whether or not view should be dismissed when the container view is tapped anywhere outside image bounds @property (nonatomic, assign) BOOL shouldDismissOnTap; // determines whether or not view should be dismissed when the container view is tapped within bounds of image view diff --git a/URBMediaFocusViewController.m b/URBMediaFocusViewController.m index 8383b0a..b4d1df3 100644 --- a/URBMediaFocusViewController.m +++ b/URBMediaFocusViewController.m @@ -225,8 +225,8 @@ - (void)showImage:(UIImage *)image fromRect:(CGRect)fromRect { self.imageView.alpha = 0.2; // create snapshot of background if parallax is enabled - if (self.parallaxEnabled) { - [self createViewsForParallax]; + if (self.parallaxEnabled || self.shouldBlurBackground) { + [self createViewsForBackground]; // hide status bar, but store whether or not we need to unhide it later when dismissing this view // NOTE: in iOS 7+, this only works if you set `UIViewControllerBasedStatusBarAppearance` to YES in your Info.plist @@ -310,8 +310,10 @@ - (void)showImage:(UIImage *)image fromRect:(CGRect)fromRect { if (self.snapshotView) { self.blurredSnapshotView.alpha = 1.0f; - self.blurredSnapshotView.transform = CGAffineTransformScale(CGAffineTransformIdentity, __backgroundScale, __backgroundScale); - self.snapshotView.transform = CGAffineTransformScale(CGAffineTransformIdentity, __backgroundScale, __backgroundScale); + if (self.parallaxEnabled) { + self.blurredSnapshotView.transform = CGAffineTransformScale(CGAffineTransformIdentity, __backgroundScale, __backgroundScale); + self.snapshotView.transform = CGAffineTransformScale(CGAffineTransformIdentity, __backgroundScale, __backgroundScale); + } } } completion:^(BOOL finished) { @@ -430,10 +432,17 @@ - (UIWindow *)keyWindow { return [UIApplication sharedApplication].keyWindow; } -- (void)createViewsForParallax { +- (void)createViewsForBackground { // container view for window + CGRect containerFrame = CGRectMake(0, 0, CGRectGetWidth(self.keyWindow.frame), CGRectGetHeight(self.keyWindow.frame)); + // inset container view so we can blur the edges, but we also need to scale up so when __backgroundScale is applied, everything lines up - CGRect containerFrame = CGRectMake(0, 0, CGRectGetWidth(self.keyWindow.frame) * (1.0f / __backgroundScale), CGRectGetHeight(self.keyWindow.frame) * (1.0f / __backgroundScale)); + // only perform inset if `parallaxEnabled` is YES + if (self.parallaxEnabled) { + containerFrame.size.width *= 1.0f / __backgroundScale; + containerFrame.size.height *= 1.0f / __backgroundScale; + } + UIView *containerView = [[UIView alloc] initWithFrame:CGRectIntegral(containerFrame)]; containerView.backgroundColor = [UIColor blackColor];