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

Added properties for customizations. #205

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
4 changes: 4 additions & 0 deletions Example/NYTViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ @interface NYTViewController () <NYTPhotosViewControllerDelegate>
@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];

Expand Down
2 changes: 1 addition & 1 deletion NYTPhotoViewer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion NYTPhotoViewer/NYTPhotoViewerSinglePhotoDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 5 additions & 0 deletions NYTPhotoViewer/NYTPhotosOverlayView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
6 changes: 4 additions & 2 deletions NYTPhotoViewer/NYTPhotosOverlayView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -93,6 +91,10 @@ - (void)setupNavigationBar {
}
}

-(void)setBackgroundColor:(UIColor *)backgroundColor{
self.navigationBar.backgroundColor = backgroundColor;
}

- (void)setCaptionView:(UIView *)captionView {
if (self.captionView == captionView) {
return;
Expand Down
17 changes: 16 additions & 1 deletion NYTPhotoViewer/NYTPhotosViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NSString *, id> *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.
*/
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 13 additions & 2 deletions NYTPhotoViewer/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -314,6 +317,14 @@ - (void)displayActivityViewController:(UIActivityViewController *)controller ani
}
}

-(void)setTitleTextAttributes:(NSDictionary<NSString *,id> *)titleTextAttributes{
_titleTextAttributes = titleTextAttributes;
}

-(void)setIsTitleBackgroundSolid:(BOOL)isTitleBackgroundSolid{
_isTitleBackgroundSolid = isTitleBackgroundSolid;
}

- (UIBarButtonItem *)leftBarButtonItem {
return self.overlayView.leftBarButtonItem;
}
Expand Down