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 text ( center aligned) doesn't show up in iPhone X #226

Open
vamshikpadala opened this issue Oct 3, 2017 · 9 comments
Open

Comments

@vamshikpadala
Copy link

Hi Guys, i've encountered an issue with the CRToastTypeStatusBar. The texts which are aligned center in the status bar presenter are not showing up in iPhone X. I am attaching the screenshot as well. Could you please let me know if there is any alternative for this behavior or are you guys updating the library any where soon?
simulator screen shot - iphone x - 2017-09-22 at 09 41 23

Above red marked area is where i have my text. I really appreciate your work with CRToast. Thanks.

@mavris
Copy link

mavris commented Oct 3, 2017

Came exactly for the same issue. Is there any chance to show the notification under the navigation bar?

@vamshikpadala
Copy link
Author

Hey mavris, as far as i know, you can show it as a navigationBar. But under the navigation bar, i am not sure.

@chessboy
Copy link

chessboy commented Oct 4, 2017

It seems the library needs to be updated to take into account the new "Safe Area" released in iOS 11. Not sure how that would work on an iPhone X running iOS 10 (if that's even possible). Love CRToast – please make this happen!

@Double-Dude
Copy link

Same to me, part of the Title text got covered by the motion detector area(top centre). Stupid iPhone X design.

@Ashton-W
Copy link
Collaborator

Ashton-W commented Oct 4, 2017

My recommendation would to be stop using the status bar for toasts.
You could detect the device and change to navigation bar toasts - or move to navigation bar toasts entirely.

@mavris
Copy link

mavris commented Oct 4, 2017

Can you move the toast to a custom location? If yes, how? Documentation is terrible

@Double-Dude
Copy link

@Ashton-W Even I change to navigation bar toasts, part of the text still got covered by the area.

@Ashton-W
Copy link
Collaborator

Ashton-W commented Oct 5, 2017

Try not using over status bar too, we would need to add code to be aware of safe area to fix it otherwise

@dmiedema
Copy link
Contributor

dmiedema commented Oct 5, 2017

⚠️ Warning ⚠️: This is not well tested

You can apply a really dirty hack to shift the text down only on the iPhone X.

In CRToast.m -layoutSubviews add a check to see if the status bar frame is taller than 20. Again, this is hardly tested so it may totally fall over in some circumstances but it at least works in the demo app

If someone has the time to properly test this a build out a better solution please do - I unfortunately do not have the time but just found this kind of worked or at least was a starting point.

Screen Shot & git diff here

diff --git a/CRToast/CRToastView.m b/CRToast/CRToastView.m
index 8a9518d..ce2d2c4 100644
--- a/CRToast/CRToastView.m
+++ b/CRToast/CRToastView.m
@@ -132,6 +132,9 @@ static CGFloat CRCenterXForActivityIndicatorWithAlignment(CRToastAccessoryViewAl
     CGFloat preferredPadding = self.toast.preferredPadding;
     
     CGFloat statusBarYOffset = self.toast.displayUnderStatusBar ? (CRGetStatusBarHeight()+CRStatusBarViewUnderStatusBarYOffsetAdjustment) : 0;
+    if (CRGetStatusBarHeight() > 20) {
+        statusBarYOffset += 24;
+    }
     contentFrame.size.height = CGRectGetHeight(contentFrame) - statusBarYOffset;

screen shot 2017-10-05 at 9 02 28 am

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

No branches or pull requests

6 participants