diff --git a/Example/NYTViewController.m b/Example/NYTViewController.m index 6a504027..21f18aeb 100644 --- a/Example/NYTViewController.m +++ b/Example/NYTViewController.m @@ -31,9 +31,13 @@ @interface NYTViewController () @implementation NYTViewController - (IBAction)imageButtonTapped:(id)sender { + self.dataSource = [self.class newTimesBuildingDataSource]; NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithDataSource:self.dataSource initialPhoto:nil delegate:self]; + photosViewController.delegate = self; + photosViewController.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName : [UIFont fontWithName:@"Arial" size:20.0]}; + photosViewController.isTitleBackgroundSolid = YES; [self presentViewController:photosViewController animated:YES completion:nil]; diff --git a/NYTPhotoViewer.podspec b/NYTPhotoViewer.podspec index 6fe70c84..8631eb31 100644 --- a/NYTPhotoViewer.podspec +++ b/NYTPhotoViewer.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.license = { :type => 'Apache 2.0' } s.source = { :git => "https://github.com/NYTimes/NYTPhotoViewer.git", :tag => s.version.to_s } - s.platform = :ios, '8.0' + s.platform = :ios, '9.0' s.requires_arc = true s.subspec 'Core' do |ss| diff --git a/NYTPhotoViewer/NYTPhotoViewerSinglePhotoDataSource.h b/NYTPhotoViewer/NYTPhotoViewerSinglePhotoDataSource.h index 65edcc56..4d4e15c7 100644 --- a/NYTPhotoViewer/NYTPhotoViewerSinglePhotoDataSource.h +++ b/NYTPhotoViewer/NYTPhotoViewerSinglePhotoDataSource.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN /** * The designated initializer that takes and stores a single photo. * - * @param photos An object conforming to the `NYTPhoto` protocol. + * @param photo An object conforming to the `NYTPhoto` protocol. * * @return A fully initialized data source. */ diff --git a/NYTPhotoViewer/NYTPhotosOverlayView.h b/NYTPhotoViewer/NYTPhotosOverlayView.h index f62c52dd..7314f714 100644 --- a/NYTPhotoViewer/NYTPhotosOverlayView.h +++ b/NYTPhotoViewer/NYTPhotosOverlayView.h @@ -25,6 +25,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, copy, nullable) NSString *title; +/** + * The overlay title background color + */ +@property (nonatomic) UIColor * backgroundColor; + /** * The attributes of the overlay's title. */ diff --git a/NYTPhotoViewer/NYTPhotosOverlayView.m b/NYTPhotoViewer/NYTPhotosOverlayView.m index 8ee2fb57..5a8faa0a 100644 --- a/NYTPhotoViewer/NYTPhotosOverlayView.m +++ b/NYTPhotoViewer/NYTPhotosOverlayView.m @@ -68,8 +68,6 @@ - (void)setupNavigationBar { self.navigationBar = [[UINavigationBar alloc] init]; self.navigationBar.translatesAutoresizingMaskIntoConstraints = NO; - // Make navigation bar background fully transparent. - self.navigationBar.backgroundColor = [UIColor clearColor]; self.navigationBar.barTintColor = nil; self.navigationBar.translucent = YES; self.navigationBar.shadowImage = [[UIImage alloc] init]; @@ -93,6 +91,10 @@ - (void)setupNavigationBar { } } +-(void)setBackgroundColor:(UIColor *)backgroundColor{ + self.navigationBar.backgroundColor = backgroundColor; +} + - (void)setCaptionView:(UIView *)captionView { if (self.captionView == captionView) { return; diff --git a/NYTPhotoViewer/NYTPhotosViewController.h b/NYTPhotoViewer/NYTPhotosViewController.h index d1cafcc7..60ea5c86 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.h +++ b/NYTPhotoViewer/NYTPhotosViewController.h @@ -75,6 +75,21 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; */ @property (nonatomic, readonly, nullable) NYTPhotosOverlayView *overlayView; +/** + * Set custom title attributes of overlayView. + */ +@property (nonatomic, copy, nullable)NSDictionary *titleTextAttributes; + +/** + * The overlay view title background. Transparent by default. If solid, color is similar with controller view. + */ +@property (nonatomic)BOOL isTitleBackgroundSolid; + +/** + * The view's background color + */ +@property (nonatomic)UIColor * backgroundColor; + /** * The left bar button item overlaying the photo. */ @@ -146,7 +161,7 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; * * This method has no effect if the given index is out of bounds in the data source. * - * @param photo The index of the photo which changed in the data source. + * @param photoIndex The index of the photo which changed in the data source. */ - (void)updatePhotoAtIndex:(NSInteger)photoIndex; diff --git a/NYTPhotoViewer/NYTPhotosViewController.m b/NYTPhotoViewer/NYTPhotosViewController.m index e089d081..8758a9b8 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.m +++ b/NYTPhotoViewer/NYTPhotosViewController.m @@ -109,7 +109,7 @@ - (void)viewDidLoad { [self configurePageViewControllerWithInitialPhoto]; self.view.tintColor = [UIColor whiteColor]; - self.view.backgroundColor = [UIColor blackColor]; + self.view.backgroundColor = self.backgroundColor?self.backgroundColor:[UIColor blackColor]; self.pageViewController.view.backgroundColor = [UIColor clearColor]; [self.pageViewController.view addGestureRecognizer:self.panGestureRecognizer]; @@ -231,7 +231,10 @@ - (void)addOverlayView { NSAssert(self.overlayView != nil, @"_overlayView must be set during initialization, to provide bar button items for this %@", NSStringFromClass([self class])); UIColor *textColor = self.view.tintColor ?: [UIColor whiteColor]; - self.overlayView.titleTextAttributes = @{NSForegroundColorAttributeName: textColor}; + + self.overlayView.titleTextAttributes = (self.titleTextAttributes)?self.titleTextAttributes:@{NSForegroundColorAttributeName: textColor}; + + self.overlayView.backgroundColor = self.isTitleBackgroundSolid?self.view.backgroundColor:[UIColor clearColor]; [self updateOverlayInformation]; [self.view addSubview:self.overlayView]; @@ -314,6 +317,14 @@ - (void)displayActivityViewController:(UIActivityViewController *)controller ani } } +-(void)setTitleTextAttributes:(NSDictionary *)titleTextAttributes{ + _titleTextAttributes = titleTextAttributes; +} + +-(void)setIsTitleBackgroundSolid:(BOOL)isTitleBackgroundSolid{ + _isTitleBackgroundSolid = isTitleBackgroundSolid; +} + - (UIBarButtonItem *)leftBarButtonItem { return self.overlayView.leftBarButtonItem; }