Skip to content

SwiftUI View ignoresSafeArea #529

Closed
Closed
@xiaoxidong

Description

For the bottom card most time need ignoresSafeArea, maybe a config for ignoresSafeArea?

Activity

wtmoose

wtmoose commented on Oct 7, 2023

@wtmoose
Member

Could you provide a screenshot + code that demonstrates the issue you're having?

xiaoxidong

xiaoxidong commented on Oct 7, 2023

@xiaoxidong
Author

1
Just the SwiftUI demo project.

wtmoose

wtmoose commented on Oct 7, 2023

@wtmoose
Member

I'm assuming you want the background to extend to the edge of the screen, but you don't want your content within the safe area. You can do that with a mask. For example, I've modified the demo app to use a mask that rounds the bottom corners and ignores the top safe area:

var body: some View {
    VStack(alignment: .leading) {
        Text(message.title).font(.system(size: 20, weight: .bold))
        Text(message.body)
    }
    .multilineTextAlignment(.leading)
    .padding(30)
    .frame(maxWidth: .infinity)
    .background(.demoMessageBackground)
    .mask(
        UnevenRoundedRectangle(
            cornerRadii: .init(bottomLeading: 15, bottomTrailing: 15)
        )
        .edgesIgnoringSafeArea(.top)
    )
}

This produces the result below. Putting your content in the safe area would require overriding the safe area insets of MessageHostingView, which isn't currently supported. However, I'm adding something to make edge styling easier and may add support for that as well.

Does this resolve your issue?

image

added a commit that references this issue on Oct 7, 2023
xiaoxidong

xiaoxidong commented on Oct 8, 2023

@xiaoxidong
Author

Great, Thank you so much.

added a commit that references this issue on Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      SwiftUI View ignoresSafeArea · Issue #529 · SwiftKickMobile/SwiftMessages