Skip to content

Commit

Permalink
allow an interstitial to NOT autotranslate masks
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-fixit committed Feb 26, 2024
1 parent 1d42d8b commit 32d0a0a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Examples/NYTPhotoViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@
11BA4B0B1C8913330007EC46 /* Frameworks */,
9EBFA0C5928F2148DEB75556 /* Pods */,
);
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 4;
};
111084071C875B5000699670 /* Products */ = {
isa = PBXGroup;
Expand Down
18 changes: 15 additions & 3 deletions NYTPhotoViewer/NYTInterstitialViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ @interface NYTInterstitialViewController ()
@property (nonatomic, nullable) id <NYTPhoto> photo;
@property (nonatomic, nullable) UIView *interstitialView;
@property (nonatomic) NSUInteger photoViewItemIndex;
@property (nonatomic, nullable) NSArray<NSLayoutConstraint *> *constraints;

- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

Expand All @@ -37,17 +38,28 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
return self;
}

- (void)prepareLayout {
if (self.interstitialView.translatesAutoresizingMaskIntoConstraints) {
self.interstitialView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
} else if (self.constraints == NULL) {
self.constraints = @[
[self.interstitialView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
[self.interstitialView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
];
[NSLayoutConstraint activateConstraints:self.constraints];
}
}

- (void)viewDidLoad {
[super viewDidLoad];

[self.view addSubview:self.interstitialView];
self.interstitialView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
[self prepareLayout];
}

- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];

self.interstitialView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
[self prepareLayout];
}

- (BOOL)prefersHomeIndicatorAutoHidden {
Expand Down

0 comments on commit 32d0a0a

Please sign in to comment.