Skip to content

NiceImage's resizable appears to be overridden by aspectRatio #71

@ssawchenko

Description

@ssawchenko

It appears that if we want an image to be resizable, we cannot set the aspectRatio modifier unless we have a known aspect ratio we want to adhere to.

This code works

struct ThemedBackground: ViewModifier {
    func body(content: Content) -> some View {
        content
            .background(
                Image("accent_background")
                    .resizable()
                    .ignoresSafeArea(.all)
            )
    }
}

adding aspect ratio breaks the resizing

struct ThemedBackground: ViewModifier {
    func body(content: Content) -> some View {
        content
            .background(
                Image("accent_background")
                    .resizable()
                    .aspectRatio(contentMode: .fill)
                    .ignoresSafeArea(.all)
            )
    }
}

Example of image not resizing:
Image

NOTE

  • Can repo on my iPhone 16 Pro running 18.6.2
  • Cannot repo on my emulated 16 plus running 18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions