diff --git a/NYTPhotoViewer/NYTPhotosViewController.h b/NYTPhotoViewer/NYTPhotosViewController.h index f67a9d6a..f69f3367 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. */ @@ -144,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 d66060cc..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]; @@ -137,8 +151,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 {