I am facing a problem: I need to create a popover with an error message for a text field. I am using .popover in the below method:
.popover(
isPresented: $isValid,
attachmentAnchor: .point(.center),
arrowEdge: .bottom
) {
Text("Some error text")
.presentationCompactAdaptation(.popover)
}
However, I am getting parasitic vertical padding at the top and bottom.
But if I use some kind of representation with exact dimensions, there are no additional insets like with Text.
.popover(
isPresented: $isValid,
attachmentAnchor: .point(.center),
arrowEdge: .bottom
) {
Rectangle().fill(.yellow)
.frame(width: 100, height: 100)
.presentationCompactAdaptation(.popover)
}
I observe the problem only with Text.
I found many solutions on stackoverflow involving bulk Extension’s with custom popover implementations.
But is there a simpler solution? I don’t want to add large custom implementations to the project purely because of the two insets.
I’ve tried a lot of options (for example, I’ve tried using ScrollView for Text) trying to get rid of the vertical padding and make the popover wrap the Text to fit the content, but I haven’t been able to.
If anyone knows what the issue is, please help me out =)
p.s. target: ios16




