SwiftMessages icon indicating copy to clipboard operation
SwiftMessages copied to clipboard

Message Over the Status Bar

Open tomasbek opened this issue 7 years ago • 7 comments

Hello,

I need to show a message over the status bar. However, the message covers navigation button on the iPhone X as you can see in this screenshot: simulator screen shot - iphone x - 2018-09-06 at 23 07 02 The configuration I use is as follows:

    warningConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)

What could be done to avoid this problem?

Thank you very much!

tomasbek avatar Sep 06 '18 20:09 tomasbek

Why not reduce the height of the message?

wtmoose avatar Sep 06 '18 20:09 wtmoose

The size is fine for all models except for X. I guess that the message is 'higher' on the X due to the notch. Please take a look at the image below: untitled Is it possible to remove that empty space between the bottom of the notch and the top of the text?

tomasbek avatar Sep 06 '18 20:09 tomasbek

SwiftMessages layouts don't put content in safe areas. You can adjust messageView.layoutMarginAdditions.top on a per-device basis if the default layout don't work for you.

wtmoose avatar Sep 06 '18 21:09 wtmoose

@wtmoose, thank you very much for your suggestion. I have added this line of the code to solve the problem for the iPhone X:

messageView.layoutMarginAdditions.top = -15

For all the other models I set the top margin to 0.

Thanks again for your guidance!

tomasbek avatar Sep 07 '18 06:09 tomasbek

Glad it worked.

In SwiftMessages 4, the layout you're using (it looks like .statusLine) did not cover the navigation bar. However, I made a global change in SwiftMessages 5 to keep content out of the safe area based on feedback from one of my designers. But after thinking about it more, this layout seems like a good case to break that rule and allow the label into the safe area. So I may revert back to the old behavior in a future update. I'll keep this ticket open for now.

wtmoose avatar Sep 07 '18 13:09 wtmoose

Hi Everybody, I solved the problem 👍 When you add the extension you can solve the problem: The extension function solved when you open in any view controller. The code will open with the view controller prefersStatusBarHidden.

import SwiftMessages

extension WindowViewController {
	open override var prefersStatusBarHidden: Bool {
		return UIApplication.shared.topMostViewController()?.prefersStatusBarHidden ?? false
	}
}

yunustek avatar Sep 22 '19 17:09 yunustek

Hi, I have the same issue. I used what you adviced:

SwiftMessages layouts don't put content in safe areas. You can adjust messageView.layoutMarginAdditions.top on a per-device basis if the default layout don't work for you.

That works fine but now my issue is that it's hard to tap on it to trigger the buttonTapHandler.

Any solution ?

grifas avatar Jan 07 '20 15:01 grifas