Closed borut-t closed 3 years ago
Covering the status bar hasn't been possible since iOS 13. You can hide it thought.
This is covered in the documentation:
/**
Displays the message in a new window at the specified window level.
SwiftMessages automatically increases the top margins of any message
view that adopts the `MarginInsetting` protocol (as `MessageView` does)
to account for the status bar. As of iOS 13, windows can no longer cover the
status bar. The only alternative is to set `Config.prefersStatusBarHidden = true`
to hide it.
*/
case window(windowLevel: UIWindow.Level)
I do need to update the readme.
@wtmoose sorry for the confusion. I don't want to cover the status, but show banner bellow it and cover navigation bar.
config.presentationContext = .window(windowLevel: .normal)
@wtmoose I don't get it. It covers the navigation bar just by half. I would expect to fully cover it.
Also, I cannot get the title
to be visible π€
Here is the code:
let view = MessageView.viewFromNib(layout: .statusLine)
view.configureContent(title: "No internet connection.", body: "")
view.bodyLabel?.isHidden = true
view.configureTheme(.warning)
view.configureTheme(backgroundColor: .init(red: 255, green: 116, blue: 116), foregroundColor: .white)
view.button?.isHidden = true
var config = SwiftMessages.defaultConfig
config.duration = .forever
config.presentationStyle = .top
config.presentationContext = .window(windowLevel: .normal)
config.interactiveHide = false
SwiftMessages.show(config: config, view: view)
The the .statusLine
layout you're using was designed to be a 20pt tall bar with a single line of text covering the 20pt status bar on pre-notch phones. The height you see is what you get on a notched phone βΒ it extends far enough below the notch to fit the line of text.
The .statusLine
view has only a single element β a label connected to the bodyLabel
outlet β which you've hidden. There is no title.
The layouts provided with SwiftMessages are designed to size to fit the content. There is no layout specifically designed to precisely cover the navigation bar.
If you don't have enough content to cover the bar, you can add an explicit height constraint.
Thanks, @wtmoose for an explanation. I think it would be worth mentioning the behaviour of all predefined layouts how they are used and what are defaults.
For my case, I've decided to go with backgroundHeight
.
@wtmoose smth still baffles me. In my setup (tabBar + navBar), the top inset on notch device is 88 pts. When I set this value for backgroundHeight
, the banner doesn't fully cover navBar, but it should. So my guess is that the view is offset up a bit to compensate for the bouncing animation. Is that correct? If so, can make sure that the given backgroundHeight
gets respected?
bounceAnimationOffset
is an exposed property on the view that you can change or add to your background height.
@wtmoose that helps thanks π
I want to show message over statusBar and navigationBar. I just can't figure out how to make this happen with this library. Can you give me some suggestions?