Skip to content

Commit

Permalink
Merge pull request #192 from motoshima1150/fix-page-control-issue
Browse files Browse the repository at this point in the history
Fix page control padding on iPhone X
  • Loading branch information
mamaral authored Nov 28, 2017
2 parents 8f9c573 + 740673f commit fd44e44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Source/OnboardingContentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ - (void)viewWillLayoutSubviews {
if (self.videoURL) {
self.moviePlayerController.view.frame = self.view.frame;
}


CGFloat safedUnderPageControlPadding = self.underPageControlPadding;
if (@available(iOS 11.0, *)) {
safedUnderPageControlPadding += [self.view safeAreaInsets].bottom;
}

CGFloat viewWidth = CGRectGetWidth(self.view.frame);
CGFloat contentWidth = viewWidth * kContentWidthMultiplier;
CGFloat xPadding = (viewWidth - contentWidth) / 2.0;
Expand All @@ -284,7 +289,7 @@ - (void)viewWillLayoutSubviews {
[self.bodyLabel sizeToFit];
self.bodyLabel.frame = CGRectMake(xPadding, bodyYOrigin, contentWidth, CGRectGetHeight(self.bodyLabel.frame));

self.actionButton.frame = CGRectMake((CGRectGetMaxX(self.view.frame) / 2) - (contentWidth / 2), CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kMainPageControlHeight - kActionButtonHeight - self.bottomPadding, contentWidth, kActionButtonHeight);
self.actionButton.frame = CGRectMake((CGRectGetMaxX(self.view.frame) / 2) - (contentWidth / 2), CGRectGetMaxY(self.view.frame) - safedUnderPageControlPadding - kMainPageControlHeight - kActionButtonHeight - self.bottomPadding, contentWidth, kActionButtonHeight);
}


Expand Down
9 changes: 7 additions & 2 deletions Source/OnboardingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ - (void)viewWillDisappear:(BOOL)animated {
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];

CGFloat safedUnderPageControlPadding = self.underPageControlPadding;
if (@available(iOS 11.0, *)) {
safedUnderPageControlPadding += [self.view safeAreaInsets].bottom;
}

self.pageVC.view.frame = self.view.frame;
self.moviePlayerController.view.frame = self.view.frame;
self.skipButton.frame = CGRectMake(CGRectGetMaxX(self.view.frame) - kSkipButtonWidth, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kSkipButtonHeight, kSkipButtonWidth, kSkipButtonHeight);
self.pageControl.frame = CGRectMake(0, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kPageControlHeight, self.view.frame.size.width, kPageControlHeight);
self.skipButton.frame = CGRectMake(CGRectGetMaxX(self.view.frame) - kSkipButtonWidth, CGRectGetMaxY(self.view.frame) - safedUnderPageControlPadding - kSkipButtonHeight, kSkipButtonWidth, kSkipButtonHeight);
self.pageControl.frame = CGRectMake(0, CGRectGetMaxY(self.view.frame) - safedUnderPageControlPadding - kPageControlHeight, self.view.frame.size.width, kPageControlHeight);
}

- (void)generateView {
Expand Down

0 comments on commit fd44e44

Please sign in to comment.