From e8916b7a899d039d0bb8e4497934f1cafb3f2361 Mon Sep 17 00:00:00 2001 From: Vyacheslav Ksenofontov Date: Fri, 17 Jul 2020 14:26:27 +0300 Subject: [PATCH] fixed gradientLayer for safe area ttps://github.com/nytimes/NYTPhotoViewer/pull/264 fixed zoom: set 3x --- NYTPhotoViewer/NYTPhotoCaptionView.m | 19 +++++++++++++++++-- NYTPhotoViewer/NYTScalingImageView.m | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/NYTPhotoViewer/NYTPhotoCaptionView.m b/NYTPhotoViewer/NYTPhotoCaptionView.m index 7c28299c..4abe69ce 100644 --- a/NYTPhotoViewer/NYTPhotoCaptionView.m +++ b/NYTPhotoViewer/NYTPhotoCaptionView.m @@ -59,7 +59,8 @@ - (void)layoutSubviews { [super layoutSubviews]; void (^updateGradientFrame)(void) = ^{ - self.gradientLayer.frame = self.layer.bounds; + //self.gradientLayer.frame = self.layer.bounds; + [self updateGradientLayerFrame]; //VK }; updateGradientFrame(); @@ -130,11 +131,25 @@ - (void)setupTextView { - (void)setupGradient { self.gradientLayer = [CAGradientLayer layer]; - self.gradientLayer.frame = self.layer.bounds; + //self.gradientLayer.frame = self.layer.bounds; + [self updateGradientLayerFrame]; //VK self.gradientLayer.colors = [NSArray arrayWithObjects:(id)[UIColor clearColor].CGColor, (id)[[UIColor blackColor] colorWithAlphaComponent:0.85].CGColor, nil]; [self.layer insertSublayer:self.gradientLayer atIndex:0]; } +- (void)updateGradientLayerFrame { // VK https://github.com/nytimes/NYTPhotoViewer/pull/264/files + if (true/*self.respectsSafeArea*/) { + UIEdgeInsets safeAreaInsets = [[UIApplication sharedApplication] keyWindow].safeAreaInsets; + CGRect selfBounds = self.layer.bounds; + self.gradientLayer.frame = CGRectMake(selfBounds.origin.x - safeAreaInsets.left, + selfBounds.origin.y + safeAreaInsets.bottom, + selfBounds.size.width + safeAreaInsets.left + safeAreaInsets.right, + selfBounds.size.height + safeAreaInsets.bottom); + } else { + self.gradientLayer.frame = self.layer.bounds; + } +} + - (void)updateTextViewAttributedText { NSMutableAttributedString *attributedLabelText = [[NSMutableAttributedString alloc] init]; diff --git a/NYTPhotoViewer/NYTScalingImageView.m b/NYTPhotoViewer/NYTScalingImageView.m index a3467cad..5ce0d7e0 100644 --- a/NYTPhotoViewer/NYTScalingImageView.m +++ b/NYTPhotoViewer/NYTScalingImageView.m @@ -155,7 +155,8 @@ - (void)updateZoomScale { CGFloat minScale = MIN(scaleWidth, scaleHeight); self.minimumZoomScale = minScale; - self.maximumZoomScale = MAX(minScale, self.maximumZoomScale); + // self.maximumZoomScale = MAX(minScale, self.maximumZoomScale); + self.maximumZoomScale = minScale * 3; //VK self.zoomScale = self.minimumZoomScale;