From 06da6a02151cc5c28adddd77c9d729c7a103ac48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa?= Date: Thu, 24 Nov 2016 15:49:16 +0100 Subject: [PATCH 1/2] Show gallery under status bar option when showed. --- NYTPhotoViewer/NYTPhotosViewController.h | 5 +++++ NYTPhotoViewer/NYTPhotosViewController.m | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/NYTPhotoViewer/NYTPhotosViewController.h b/NYTPhotoViewer/NYTPhotosViewController.h index f67a9d6a..8dd3dc6e 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.h +++ b/NYTPhotoViewer/NYTPhotosViewController.h @@ -63,6 +63,11 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; */ @property (nonatomic, readonly, nullable) NYTPhotosOverlayView *overlayView; +/** + * Shows all content under status bar frame. Default NO. + */ +@property (nonatomic) BOOL underStatusBar; + /** * The left bar button item overlaying the photo. */ diff --git a/NYTPhotoViewer/NYTPhotosViewController.m b/NYTPhotoViewer/NYTPhotosViewController.m index d66060cc..f72e123a 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.m +++ b/NYTPhotoViewer/NYTPhotosViewController.m @@ -137,8 +137,14 @@ - (void)viewDidAppear:(BOOL)animated { - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; - self.pageViewController.view.frame = self.view.bounds; - self.overlayView.frame = self.view.bounds; + CGRect frame = self.view.bounds; + if (self.underStatusBar) { + CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;; + frame.origin.y = statusBarHeight; + frame.size.height -= statusBarHeight; + } + self.pageViewController.view.frame = frame; + self.overlayView.frame = frame; } - (BOOL)prefersStatusBarHidden { From 59ab398eba21b24a6e90a8359fb9e7e3629ef91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa?= Date: Wed, 20 Sep 2017 13:00:11 +0200 Subject: [PATCH 2/2] Delegate life cyble some methods --- NYTPhotoViewer/NYTPhotosViewController.h | 15 +++++++++++++++ NYTPhotoViewer/NYTPhotosViewController.m | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/NYTPhotoViewer/NYTPhotosViewController.h b/NYTPhotoViewer/NYTPhotosViewController.h index 8dd3dc6e..f69f3367 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.h +++ b/NYTPhotoViewer/NYTPhotosViewController.h @@ -149,6 +149,21 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; @optional +/** + * Called when the view is about to made visible. + * + * @param photosViewController The `NYTPhotosViewController` instance that sent the delegate message. + * @param animated + */ +- (void)photosViewController:(NYTPhotosViewController *)photosViewController viewWillAppear:(BOOL)animated; + +/** + * Called when the view is dismissed, covered or otherwise hidden. + * + * @param photosViewController The `NYTPhotosViewController` instance that sent the delegate message. + */ +- (void)photosViewController:(NYTPhotosViewController *)photosViewController viewWillDisappear:(BOOL)animated; + /** * Called when a new photo is displayed through a swipe gesture. * diff --git a/NYTPhotoViewer/NYTPhotosViewController.m b/NYTPhotoViewer/NYTPhotosViewController.m index f72e123a..aba70ae0 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.m +++ b/NYTPhotoViewer/NYTPhotosViewController.m @@ -126,6 +126,20 @@ - (void)viewDidLoad { self.transitionController.endingView = endingView; } +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + if ([_delegate respondsToSelector:@selector(photosViewController:viewWillAppear:)]) { + [_delegate photosViewController:self viewWillAppear:animated]; + } +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + if ([_delegate respondsToSelector:@selector(photosViewController:viewWillDisappear:)]) { + [_delegate photosViewController:self viewWillDisappear:animated]; + } +} + - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];