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

Switch to using topLayoutGuide to determine vertical offset #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jlorich
Copy link

@jlorich jlorich commented Mar 2, 2015

Fixes: #130 .

The status bar height changes based on in-call or navigation status, however if the ViewController has an autoResizingMaskof UIViewAutoresizingFlexibleTopMargin the ViewControllers view will already be adjusted for the increased status bar size. If a TSMessage is displayed when this is the case, it will show 24px below the navigation bar as the view is automatically adjusted for the statusBar height change, and then the TSMessageView is additionally moved down based on the new status bar size.

To fix this issue, I've changed the display position to use the viewControllers [topLayoutGuide length] as the vertical offset, as it already takes into account navigation bar and status bar size correctly. Adjustments have also been made for when the viewController is a UINavigationController subclass, since it's view is handled a bit differently.

@jlorich jlorich changed the title Switch to using topLayoutGuid to determine vertical offset Switch to using topLayoutGuide to determine vertical offset Mar 2, 2015
CGFloat verticalOffset = [[currentView.viewController topLayoutGuide] length];

if ([currentView.viewController isKindOfClass:[UINavigationController class]]) {
verticalOffset += ((UINavigationController *)currentView.viewController).toolbar.frame.size.height;
Copy link

Choose a reason for hiding this comment

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

While this works, it doesn't adapt when the top layout guide changes (such as if the user changes the orientation of their device).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSMessageView position when calling status bar is on screen
2 participants