SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.33k stars 747 forks source link

Message Over the Status Bar #221

Open tomasbek opened 6 years ago

tomasbek commented 6 years ago

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!

wtmoose commented 6 years ago

Why not reduce the height of the message?

tomasbek commented 6 years ago

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?

wtmoose commented 6 years ago

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.

tomasbek commented 6 years ago

@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!

wtmoose commented 6 years ago

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.

yunustek commented 5 years ago

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
    }
}
grifas commented 4 years ago

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 ?