In iOS 16.4 we can now use .presentationCompactAdaptation(.none) in our .popover to achieve a true popover on iOS (compact screen sizes).
SomeView()
.popover(isPresented: $isPopoverOpen) {
Text("Hello world!")
.fixedSize(horizontal: false, vertical: true)
.padding()
.presentationCompactAdaptation(.none)
}
This will give us something like:
Great, it works as expected!
The issue arises when the Text() in the popover spans multiple lines. For some reason, the popover height will only grow up to a certain height (~3 lines with non-dynamic .body font). Here is an illustration of the issue using some Lorem Ipsum text. Notice how the end gets clipped off because the popover height is too short:
How can I make the popover fit the Text() content? I can statically define the height but I would like the popover to perfectly fit the content.


You can get the height of the Text element using this approach.
For this, you get the height of the Text and set the height you received. This is how the code would look like
Popover with Long Text
Popover with Short Text
Happy Coding!