Skip to content

Commit

Permalink
fixed gradientLayer for safe area ttps://github.com/nytimes/pull/264
Browse files Browse the repository at this point in the history
fixed zoom: set 3x
  • Loading branch information
v-ksenofontov committed Jul 17, 2020
1 parent 65781ed commit e8916b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions NYTPhotoViewer/NYTPhotoCaptionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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];

Expand Down
3 changes: 2 additions & 1 deletion NYTPhotoViewer/NYTScalingImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e8916b7

Please sign in to comment.