Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions Examples/Sources/ObjC/NYTViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ - (IBAction)imageButtonTapped:(id)sender {

NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithDataSource:self.dataSource initialPhoto:nil delegate:self];

photosViewController.underStatusBar = YES;

[self presentViewController:photosViewController animated:YES completion:nil];

[self updateImagesOnPhotosViewController:photosViewController afterDelayWithDataSource:self.dataSource];
Expand Down
20 changes: 20 additions & 0 deletions NYTPhotoViewer/NYTPhotosViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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 @@ -177,6 +182,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
30 changes: 27 additions & 3 deletions NYTPhotoViewer/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,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 @@ -142,12 +156,22 @@ - (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 {
return YES;
return !self.underStatusBar;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}

- (BOOL)prefersHomeIndicatorAutoHidden {
Expand Down