From ffc7c397f983408940bbe79c345047d28658ab1b Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Tue, 5 Jan 2016 14:43:49 +1100 Subject: [PATCH 1/8] Implement first draft of `Interactive-Reload` --- Pod/Classes/ios/NYTPhotoViewController.m | 26 +++++++++++++ Pod/Classes/ios/NYTScalingImageView.m | 48 +++++++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/ios/NYTPhotoViewController.m b/Pod/Classes/ios/NYTPhotoViewController.m index 3a5627f6..920b9a51 100644 --- a/Pod/Classes/ios/NYTPhotoViewController.m +++ b/Pod/Classes/ios/NYTPhotoViewController.m @@ -10,6 +10,8 @@ #import "NYTPhoto.h" #import "NYTScalingImageView.h" +#define INTERACTIVE_RELOAD // (awyeah) + #ifdef ANIMATED_GIF_SUPPORT #import #endif @@ -200,4 +202,28 @@ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)vi } } +#ifdef INTERACTIVE_RELOAD +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { + NYTScalingImageView *scalingImageView = self.scalingImageView; + UIImageView *imageView = scalingImageView.imageView; + + CGFloat imageHeight = CGRectGetWidth(imageView.frame) * CGRectGetHeight(imageView.frame) / CGRectGetWidth(imageView.frame); + CGFloat imageWidth = CGRectGetHeight(imageView.frame) * CGRectGetWidth(imageView.frame) / CGRectGetHeight(imageView.frame); + + BOOL imageHeightSmallerThanContent = (imageHeight < scalingImageView.frame.size.height) ? YES : NO; + BOOL imageWidthSmallerThanContent = (imageWidth < scalingImageView.frame.size.width) ? YES : NO; + + CGFloat topOffset = (imageView.frame.size.height - imageHeight) / 2; + CGFloat leftOffset = (imageView.frame.size.width - imageWidth) / 2; + + if (imageHeightSmallerThanContent) { + topOffset = topOffset - ((scalingImageView.frame.size.height - imageHeight)/2); + } + + if (imageWidthSmallerThanContent) { + leftOffset = leftOffset - ((scalingImageView.frame.size.width - imageWidth)/2); + } + scalingImageView.contentInset = UIEdgeInsetsMake(topOffset * -1, leftOffset * -1, topOffset * -1, leftOffset * -1); +} +#endif @end diff --git a/Pod/Classes/ios/NYTScalingImageView.m b/Pod/Classes/ios/NYTScalingImageView.m index 4f25032f..126eac1c 100644 --- a/Pod/Classes/ios/NYTScalingImageView.m +++ b/Pod/Classes/ios/NYTScalingImageView.m @@ -14,6 +14,12 @@ #import #endif +#define INTERACTIVE_RELOAD // (awyeah) + +#ifdef INTERACTIVE_RELOAD +#define IsValidZoomScale(zoomScale) (zoomScale != 0 && zoomScale != 1) +#endif + @interface NYTScalingImageView () - (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; @@ -23,6 +29,10 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; #else @property (nonatomic) UIImageView *imageView; #endif + +@property (nonatomic) CGFloat baseZoomScale; +@property (nonatomic) CGSize baseSize; + @end @implementation NYTScalingImageView @@ -109,7 +119,9 @@ - (void)updateImage:(UIImage *)image imageData:(NSData *)imageData { UIImage *imageToUse = image ?: [UIImage imageWithData:imageData]; // Remove any transform currently applied by the scroll view zooming. +#ifndef INTERACTIVE_RELOAD self.imageView.transform = CGAffineTransformIdentity; +#endif self.imageView.image = imageToUse; #ifdef ANIMATED_GIF_SUPPORT @@ -117,12 +129,23 @@ - (void)updateImage:(UIImage *)image imageData:(NSData *)imageData { self.imageView.animatedImage = [[FLAnimatedImage alloc] initWithAnimatedGIFData:imageData]; #endif +#ifndef INTERACTIVE_RELOAD self.imageView.frame = CGRectMake(0, 0, imageToUse.size.width, imageToUse.size.height); +#endif self.contentSize = imageToUse.size; +#ifdef INTERACTIVE_RELOAD + self.baseZoomScale = self.zoomScale; + if (CGSizeEqualToSize(self.baseSize, CGSizeZero)) { + self.baseSize = image.size; + } +#endif [self updateZoomScale]; + +#ifndef INTERACTIVE_RELOAD [self centerScrollViewContents]; +#endif } - (void)setupImageScrollView { @@ -141,22 +164,37 @@ - (void)updateZoomScale { #endif CGRect scrollViewFrame = self.bounds; +#ifdef INTERACTIVE_RELOAD + CGFloat scaleWidth = scrollViewFrame.size.width / self.baseSize.width; + CGFloat scaleHeight = scrollViewFrame.size.height / self.baseSize.height; +#else CGFloat scaleWidth = scrollViewFrame.size.width / self.imageView.image.size.width; CGFloat scaleHeight = scrollViewFrame.size.height / self.imageView.image.size.height; +#endif CGFloat minScale = MIN(scaleWidth, scaleHeight); self.minimumZoomScale = minScale; self.maximumZoomScale = MAX(minScale, self.maximumZoomScale); +#ifdef INTERACTIVE_RELOAD + if (IsValidZoomScale(self.baseZoomScale)) { + self.zoomScale = self.baseZoomScale; + } else { + self.zoomScale = self.minimumZoomScale; + } + self.baseZoomScale = self.zoomScale; +#else self.zoomScale = self.minimumZoomScale; - +#endif // scrollView.panGestureRecognizer.enabled is on by default and enabled by // viewWillLayoutSubviews in the container controller so disable it here // to prevent an interference with the container controller's pan gesture. // // This is enabled in scrollViewWillBeginZooming so panning while zoomed-in // is unaffected. +#ifndef INTERACTIVE_RELOAD self.panGestureRecognizer.enabled = NO; +#endif } } @@ -167,11 +205,19 @@ - (void)centerScrollViewContents { CGFloat verticalInset = 0; if (self.contentSize.width < CGRectGetWidth(self.bounds)) { +#ifdef INTERACTIVE_RELOAD + horizontalInset = (CGRectGetWidth(self.bounds) - self.baseSize.width) * 0.5; +#else horizontalInset = (CGRectGetWidth(self.bounds) - self.contentSize.width) * 0.5; +#endif } if (self.contentSize.height < CGRectGetHeight(self.bounds)) { +#ifdef INTERACTIVE_RELOAD + verticalInset = (CGRectGetHeight(self.bounds) - self.baseSize.height) * 0.5; +#else verticalInset = (CGRectGetHeight(self.bounds) - self.contentSize.height) * 0.5; +#endif } if (self.window.screen.scale < 2.0) { From 0acee28a7bd0c1629de8987fc4bd894616f72758 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Wed, 6 Jan 2016 13:47:17 +1100 Subject: [PATCH 2/8] Fixes image jumping issue when loading full size image --- Pod/Classes/ios/NYTScalingImageView.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Pod/Classes/ios/NYTScalingImageView.m b/Pod/Classes/ios/NYTScalingImageView.m index 126eac1c..2022af35 100644 --- a/Pod/Classes/ios/NYTScalingImageView.m +++ b/Pod/Classes/ios/NYTScalingImageView.m @@ -227,6 +227,11 @@ - (void)centerScrollViewContents { // Use `contentInset` to center the contents in the scroll view. Reasoning explained here: http://petersteinberger.com/blog/2013/how-to-center-uiscrollview/ self.contentInset = UIEdgeInsetsMake(verticalInset, horizontalInset, verticalInset, horizontalInset); + +#ifdef INTERACTIVE_RELOAD + // Fixes image jumping issue when loading full size image + [self.delegate scrollViewDidScroll:self]; +#endif } @end From da4d1929f32fc19dde9a737685a51b5df36266a7 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Thu, 7 Jan 2016 08:57:24 +1100 Subject: [PATCH 3/8] Make delegate call safe --- Pod/Classes/ios/NYTScalingImageView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/ios/NYTScalingImageView.m b/Pod/Classes/ios/NYTScalingImageView.m index 2022af35..a804809e 100644 --- a/Pod/Classes/ios/NYTScalingImageView.m +++ b/Pod/Classes/ios/NYTScalingImageView.m @@ -230,7 +230,9 @@ - (void)centerScrollViewContents { #ifdef INTERACTIVE_RELOAD // Fixes image jumping issue when loading full size image - [self.delegate scrollViewDidScroll:self]; + if ([self.delegate respondsToSelector:@selector(scrollViewDidScroll:)]) { + [self.delegate scrollViewDidScroll:self]; + } #endif } From ce399e4ab363d953b32eb9e43fbbf78423c05726 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Fri, 15 Jan 2016 10:26:53 +1100 Subject: [PATCH 4/8] Add shadow to UINavigationBar --- Pod/Classes/ios/NYTPhotosOverlayView.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.m b/Pod/Classes/ios/NYTPhotosOverlayView.m index b58542ce..c80be5ce 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.m +++ b/Pod/Classes/ios/NYTPhotosOverlayView.m @@ -12,6 +12,7 @@ @interface NYTPhotosOverlayView () @property (nonatomic) UINavigationItem *navigationItem; @property (nonatomic) UINavigationBar *navigationBar; +@property (nonatomic) CAGradientLayer *gradientLayer; @end @@ -49,6 +50,7 @@ - (void)layoutSubviews { }]; [super layoutSubviews]; + self.gradientLayer.frame = self.navigationBar.bounds; } #pragma mark - NYTPhotosOverlayView @@ -73,6 +75,14 @@ - (void)setupNavigationBar { NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:self.navigationBar attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0.0]; NSLayoutConstraint *horizontalPositionConstraint = [NSLayoutConstraint constraintWithItem:self.navigationBar attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]; [self addConstraints:@[topConstraint, widthConstraint, horizontalPositionConstraint]]; + [self setupGradient]; +} + +- (void)setupGradient { + self.gradientLayer = [CAGradientLayer layer]; + self.gradientLayer.frame = self.navigationBar.layer.bounds; + self.gradientLayer.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] colorWithAlphaComponent:0.85].CGColor, (id)[UIColor clearColor].CGColor, nil]; + [self.navigationBar.layer insertSublayer:self.gradientLayer atIndex:1]; } - (void)setCaptionView:(UIView *)captionView { From 22077a61f14ae3547146d63bbc730faa17cc9ecb Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Fri, 15 Jan 2016 13:04:57 +1100 Subject: [PATCH 5/8] Add NYTLoadingIndicatorView --- Example/Pods/Pods.xcodeproj/project.pbxproj | 8 +++ Pod/Classes/ios/NYTLoadingIndicatorView.h | 18 ++++++ Pod/Classes/ios/NYTLoadingIndicatorView.m | 71 +++++++++++++++++++++ Pod/Classes/ios/NYTPhotosOverlayView.h | 6 ++ Pod/Classes/ios/NYTPhotosOverlayView.m | 10 ++- 5 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 Pod/Classes/ios/NYTLoadingIndicatorView.h create mode 100644 Pod/Classes/ios/NYTLoadingIndicatorView.m diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 0323a8a2..00f68286 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -119,6 +119,8 @@ E8CDCEDCDC0ADE51EBAFCC09F44EFF12 /* OCMBlockArgCaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C4B5E15B42999732406D11FF27399E /* OCMBlockArgCaller.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; E99CE64289F5FDD09B7E1188379AED41 /* FLAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 0302D606627AFF213D39DE2877B4638D /* FLAnimatedImage.m */; }; EA2A970253EA9B298F0BB63864AA18D1 /* OCProtocolMockObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2F9528FC984AA1AC37E0C37A193A06E /* OCProtocolMockObject.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + ECBF82651C487D1000A5EC94 /* NYTLoadingIndicatorView.h in Headers */ = {isa = PBXBuildFile; fileRef = ECBF82631C487D1000A5EC94 /* NYTLoadingIndicatorView.h */; }; + ECBF82661C487D1000A5EC94 /* NYTLoadingIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = ECBF82641C487D1000A5EC94 /* NYTLoadingIndicatorView.m */; }; ED61A6F91BC025BD57D6BD2A504E1DA4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEBC85ECBD828DF92AC9EEB8B18DA6F1 /* Foundation.framework */; }; EEBEC3C68DD8C679511876B4610D582A /* OCMBoxedReturnValueProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = A9A8A71E9B0A1271A4EDDE402221428C /* OCMBoxedReturnValueProvider.h */; settings = {ATTRIBUTES = (Project, ); }; }; F0E9BE1709D8B3501A9E791E8D36FBED /* NSNotificationCenter+OCMAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0D5801E0E8C2C07D2E34E8AED0B8D3 /* NSNotificationCenter+OCMAdditions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; @@ -362,6 +364,8 @@ E9218905F90589519D5C9E501403FD5F /* NSMethodSignature+OCMAdditions.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSMethodSignature+OCMAdditions.m"; path = "Source/OCMock/NSMethodSignature+OCMAdditions.m"; sourceTree = ""; }; E93CEF5802DA5A4170AC4E23CDEBE484 /* Pods-NYTPhotoViewer-SwiftTests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-NYTPhotoViewer-SwiftTests-frameworks.sh"; sourceTree = ""; }; EA8E1E7CEE735DA4896915A276D1BC40 /* OCMMacroState.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = OCMMacroState.h; path = Source/OCMock/OCMMacroState.h; sourceTree = ""; }; + ECBF82631C487D1000A5EC94 /* NYTLoadingIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NYTLoadingIndicatorView.h; sourceTree = ""; }; + ECBF82641C487D1000A5EC94 /* NYTLoadingIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NYTLoadingIndicatorView.m; sourceTree = ""; }; EE9C5F374B788B38F7577CBACD6374D1 /* NSBundle+NYTPhotoViewer.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "NSBundle+NYTPhotoViewer.h"; sourceTree = ""; }; F170EA151A6B5BB3B1185891240455B8 /* OCMVerifier.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = OCMVerifier.h; path = Source/OCMock/OCMVerifier.h; sourceTree = ""; }; F272208CEBC0979AF3E0744A2F82FDC8 /* NYTPhoto.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = NYTPhoto.h; sourceTree = ""; }; @@ -485,6 +489,8 @@ 0FCAFE0FDC5B4823AAF5C70FC8BA1EE6 /* ios */ = { isa = PBXGroup; children = ( + ECBF82631C487D1000A5EC94 /* NYTLoadingIndicatorView.h */, + ECBF82641C487D1000A5EC94 /* NYTLoadingIndicatorView.m */, 1781D669D30BF31E3D30458C11401EC4 /* NYTPhotoCaptionView.h */, 52A46719EDEA6919CB7CE89CEA7D170B /* NYTPhotoCaptionView.m */, 8E251763ABC4628F9FD370376C62339C /* NYTPhotoDismissalInteractionController.h */, @@ -893,6 +899,7 @@ buildActionMask = 2147483647; files = ( FB423EE72C2A6D0ED5DEFBEE9BE80A98 /* FLAnimatedImage.h in Headers */, + ECBF82651C487D1000A5EC94 /* NYTLoadingIndicatorView.h in Headers */, 7AE83DFAD9756ED1FB1CB5E36F9CF6EB /* FLAnimatedImageView.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1171,6 +1178,7 @@ buildActionMask = 2147483647; files = ( 3D258E9A843C52C991E5E9455CB8DB51 /* FLAnimatedImage-dummy.m in Sources */, + ECBF82661C487D1000A5EC94 /* NYTLoadingIndicatorView.m in Sources */, E99CE64289F5FDD09B7E1188379AED41 /* FLAnimatedImage.m in Sources */, B3AA789E74DBAB167DAD0FDCA19690C7 /* FLAnimatedImageView.m in Sources */, ); diff --git a/Pod/Classes/ios/NYTLoadingIndicatorView.h b/Pod/Classes/ios/NYTLoadingIndicatorView.h new file mode 100644 index 00000000..8389a16c --- /dev/null +++ b/Pod/Classes/ios/NYTLoadingIndicatorView.h @@ -0,0 +1,18 @@ +// +// NYTLoadingIndicatorView.h +// Pods +// +// Created by Marcus Kida on 15/01/2016. +// +// + +#import + +@interface NYTLoadingIndicatorView : UIView + +/** + * The progress to be shown, raning 0.0 to 1.0 + */ +@property (nonatomic, assign) CGFloat progress; + +@end diff --git a/Pod/Classes/ios/NYTLoadingIndicatorView.m b/Pod/Classes/ios/NYTLoadingIndicatorView.m new file mode 100644 index 00000000..3407c61c --- /dev/null +++ b/Pod/Classes/ios/NYTLoadingIndicatorView.m @@ -0,0 +1,71 @@ +// +// NYTLoadingIndicatorView.m +// Pods +// +// Created by Marcus Kida on 15/01/2016. +// +// + +#import "NYTLoadingIndicatorView.h" + +@interface NYTLoadingIndicatorView () + +@property (nonatomic) UIView *indicatorView; + +@end + +@implementation NYTLoadingIndicatorView + +- (instancetype)init { + self = [super init]; + if (self) { + [self setup]; + } + return self; +} + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self setup]; + } + return self; +} + +- (void)setup { + self.backgroundColor = [UIColor clearColor]; + self.indicatorView = [[UIView alloc] init]; + self.indicatorView.backgroundColor = [UIColor whiteColor]; + [self addSubview:self.indicatorView]; +} + +- (void)setFrame:(CGRect)frame { + [super setFrame:frame]; + [self updateIndicatorView]; +} + +- (void)resetIndicatorHidden:(BOOL)hidden { + self.indicatorView.frame = (CGRect){0, 0, 0, self.bounds.size.height}; + self.indicatorView.hidden = hidden; +} + +- (void)updateIndicatorView { + if (self.progress == 0.0f) { + return [self resetIndicatorHidden:NO]; + } + if (self.progress >= 1.0f) { + return [self resetIndicatorHidden:YES]; + } + self.indicatorView.frame = (CGRect){0, 0, [self progressWidth:self.progress], self.bounds.size.height}; +} + +- (CGFloat)progressWidth:(CGFloat)progress { + return (self.bounds.size.width / 100) * (progress * 100); +} + +- (void)setProgress:(CGFloat)progress { + _progress = progress; + [self updateIndicatorView]; +} + +@end diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.h b/Pod/Classes/ios/NYTPhotosOverlayView.h index cca8d9d4..5d4d380c 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.h +++ b/Pod/Classes/ios/NYTPhotosOverlayView.h @@ -7,6 +7,7 @@ // @import UIKit; +@class NYTLoadingIndicatorView; NS_ASSUME_NONNULL_BEGIN @@ -55,6 +56,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, nullable) UIView *captionView; +/** + * Loading indicator shown at the top + */ +@property (nonatomic, nullable) NYTLoadingIndicatorView *loadingIndicatorView; + @end NS_ASSUME_NONNULL_END diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.m b/Pod/Classes/ios/NYTPhotosOverlayView.m index fc001066..bfb92fdd 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.m +++ b/Pod/Classes/ios/NYTPhotosOverlayView.m @@ -8,6 +8,7 @@ #import "NYTPhotosOverlayView.h" #import "NYTPhotoCaptionViewLayoutWidthHinting.h" +#import "NYTLoadingIndicatorView.h" @interface NYTPhotosOverlayView () @@ -25,8 +26,9 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self) { [self setupNavigationBar]; + [self setupLoadingIndicator]; } - + return self; } @@ -50,13 +52,17 @@ - (void)layoutSubviews { }]; [super layoutSubviews]; - + self.loadingIndicatorView.frame = (CGRect){0, 0, self.bounds.size.width, 2}; if ([self.captionView conformsToProtocol:@protocol(NYTPhotoCaptionViewLayoutWidthHinting)]) { [(id) self.captionView setPreferredMaxLayoutWidth:self.bounds.size.width]; } } #pragma mark - NYTPhotosOverlayView +- (void)setupLoadingIndicator { + self.loadingIndicatorView = [[NYTLoadingIndicatorView alloc] init]; + [self addSubview:self.loadingIndicatorView]; +} - (void)setupNavigationBar { self.navigationBar = [[UINavigationBar alloc] init]; From 50896f567c00eaed1aacbd91d8801142c1e7c17f Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Fri, 15 Jan 2016 13:13:54 +1100 Subject: [PATCH 6/8] Make UINavigaitonBar gradient configurable --- Pod/Classes/ios/NYTPhotosOverlayView.h | 5 +++++ Pod/Classes/ios/NYTPhotosOverlayView.m | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.h b/Pod/Classes/ios/NYTPhotosOverlayView.h index cca8d9d4..5dc0a969 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.h +++ b/Pod/Classes/ios/NYTPhotosOverlayView.h @@ -55,6 +55,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, nullable) UIView *captionView; +/** + * Enables or disables gradient behind UINavigaitonBar + */ +@property (nonatomic, assign, getter=hasNavigationBarGradient) BOOL navigationBarGradient; + @end NS_ASSUME_NONNULL_END diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.m b/Pod/Classes/ios/NYTPhotosOverlayView.m index 591f4575..e9f43e1c 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.m +++ b/Pod/Classes/ios/NYTPhotosOverlayView.m @@ -51,7 +51,7 @@ - (void)layoutSubviews { }]; [super layoutSubviews]; - self.gradientLayer.frame = self.navigationBar.bounds; + [self layoutNavbarGradient]; if ([self.captionView conformsToProtocol:@protocol(NYTPhotoCaptionViewLayoutWidthHinting)]) { [(id) self.captionView setPreferredMaxLayoutWidth:self.bounds.size.width]; @@ -80,7 +80,6 @@ - (void)setupNavigationBar { NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:self.navigationBar attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0.0]; NSLayoutConstraint *horizontalPositionConstraint = [NSLayoutConstraint constraintWithItem:self.navigationBar attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]; [self addConstraints:@[topConstraint, widthConstraint, horizontalPositionConstraint]]; - [self setupGradient]; } - (void)setupGradient { @@ -90,6 +89,12 @@ - (void)setupGradient { [self.navigationBar.layer insertSublayer:self.gradientLayer atIndex:1]; } +- (void)layoutNavbarGradient { + if (self.gradientLayer) { + self.gradientLayer.frame = self.navigationBar.bounds; + } +} + - (void)setCaptionView:(UIView *)captionView { if (self.captionView == captionView) { return; @@ -156,4 +161,14 @@ - (void)setTitleTextAttributes:(NSDictionary *)titleTextAttributes { self.navigationBar.titleTextAttributes = titleTextAttributes; } +- (void)setNavigationBarGradient:(BOOL)navigationBarGradient { + if (_navigationBarGradient) { + [self.gradientLayer removeFromSuperlayer]; + } + if (navigationBarGradient) { + [self setupGradient]; + } + _navigationBarGradient = navigationBarGradient; +} + @end From 89f2d83ab399d241eb90231eeb93e8a57a814f67 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Mon, 8 Feb 2016 10:49:16 +1100 Subject: [PATCH 7/8] Add `INTERACTIVE_RELOAD` to `Podspec` --- NYTPhotoViewer.podspec | 2 +- Pod/Classes/ios/NYTPhotoViewController.m | 2 +- Pod/Classes/ios/NYTScalingImageView.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NYTPhotoViewer.podspec b/NYTPhotoViewer.podspec index b2c71a83..b6043159 100644 --- a/NYTPhotoViewer.podspec +++ b/NYTPhotoViewer.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| end s.subspec 'AnimatedGifSupport' do |ss| - ss.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'ANIMATED_GIF_SUPPORT=1'} + ss.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'ANIMATED_GIF_SUPPORT=1 INTERACTIVE_RELOAD=1'} ss.dependency 'NYTPhotoViewer/Core' ss.dependency 'FLAnimatedImage', '~> 1.0.8' diff --git a/Pod/Classes/ios/NYTPhotoViewController.m b/Pod/Classes/ios/NYTPhotoViewController.m index 5472a5ee..39d2fc77 100644 --- a/Pod/Classes/ios/NYTPhotoViewController.m +++ b/Pod/Classes/ios/NYTPhotoViewController.m @@ -10,7 +10,7 @@ #import "NYTPhoto.h" #import "NYTScalingImageView.h" -#define INTERACTIVE_RELOAD // (awyeah) +#define INTERACTIVE_RELOAD #ifdef ANIMATED_GIF_SUPPORT #import diff --git a/Pod/Classes/ios/NYTScalingImageView.m b/Pod/Classes/ios/NYTScalingImageView.m index d23bdbce..e9c78a7b 100644 --- a/Pod/Classes/ios/NYTScalingImageView.m +++ b/Pod/Classes/ios/NYTScalingImageView.m @@ -14,7 +14,7 @@ #import #endif -#define INTERACTIVE_RELOAD // (awyeah) +#define INTERACTIVE_RELOAD #ifdef INTERACTIVE_RELOAD #define IsValidZoomScale(zoomScale) (zoomScale != 0 && zoomScale != 1) From b64916f59a56af2b630997be55b4cc22d9bdf8b8 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Mon, 8 Feb 2016 10:50:07 +1100 Subject: [PATCH 8/8] Fix typo --- Pod/Classes/ios/NYTLoadingIndicatorView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/ios/NYTLoadingIndicatorView.h b/Pod/Classes/ios/NYTLoadingIndicatorView.h index 8389a16c..6fd1d37b 100644 --- a/Pod/Classes/ios/NYTLoadingIndicatorView.h +++ b/Pod/Classes/ios/NYTLoadingIndicatorView.h @@ -11,7 +11,7 @@ @interface NYTLoadingIndicatorView : UIView /** - * The progress to be shown, raning 0.0 to 1.0 + * The progress to be shown, ranging 0.0 to 1.0 */ @property (nonatomic, assign) CGFloat progress;