Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status bar style ios7 #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions STPopup/STPopupController.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ - (void)setupObservers
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

// Observe keyboard
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Igor-Palaguta Actually it subscribes to two different events: UIKeyboardWillShowNotification and UIKeyboardWillChangeFrameNotification with the same method: keyboardWillShow. So think it's still necessary to have both of them.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

Expand Down Expand Up @@ -293,21 +292,21 @@ - (void)popViewControllerAnimated:(BOOL)animated
}

UIViewController *topViewController = [self topViewController];
topViewController.popupController = nil;
[self destroyObserversOfViewController:topViewController];
[_viewControllers removeObject:topViewController];

if (self.presented) {
[self transitFromViewController:topViewController toViewController:[self topViewController] animated:animated];
}
topViewController.popupController = nil;
}

- (void)transitFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController animated:(BOOL)animated
{
[fromViewController willMoveToParentViewController:nil];
[fromViewController beginAppearanceTransition:NO animated:animated];
[toViewController beginAppearanceTransition:YES animated:animated];

[fromViewController willMoveToParentViewController:nil];

[_containerViewController addChildViewController:toViewController];

if (animated) {
Expand Down Expand Up @@ -515,6 +514,7 @@ - (void)setup
_containerViewController = [STPopupContainerViewController new];
_containerViewController.view.backgroundColor = [UIColor clearColor];
_containerViewController.modalPresentationStyle = UIModalPresentationCustom;
_containerViewController.modalPresentationCapturesStatusBarAppearance = YES;
_containerViewController.transitioningDelegate = self;
[self setupBackgroundView];
[self setupContainerView];
Expand Down Expand Up @@ -643,9 +643,15 @@ - (void)adjustContainerViewOrigin
(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)) {
keyboardHeight = [_keyboardInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.width;
}


CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;

CGFloat offsetY = 0;
if (self.style == STPopupStyleBottomSheet) {
CGFloat windowTextFieldY = [currentTextInput convertPoint:CGPointZero toView:nil].y;
if (windowTextFieldY <= keyboardHeight) {
return;
}
offsetY = keyboardHeight;
}
else {
Expand All @@ -654,9 +660,7 @@ - (void)adjustContainerViewOrigin
if (offsetY <= 0) { // _containerView can be totally shown, so no need to reposition
return;
}

CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;


if (_containerView.frame.origin.y - offsetY < statusBarHeight) { // _containerView will be covered by status bar if it is repositioned with "offsetY"
offsetY = _containerView.frame.origin.y - statusBarHeight;
// currentTextField can not be totally shown if _containerView is going to repositioned with "offsetY"
Expand Down