Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move content under statusBar if prefersStatusBarHidden is false #221

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions NYTPhotoViewer/NYTPhotosViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*
Expand Down
24 changes: 22 additions & 2 deletions NYTPhotoViewer/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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 {
Expand Down