dmytro-anokhin / url-image

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.
MIT License
1.1k stars 96 forks source link

image does not set in frame inside ForEach #112

Closed atharvsharma1998 closed 3 years ago

atharvsharma1998 commented 3 years ago

Summary and/or background when i am using urlimage inside ForEach the images are not fitting inside defined frame

OS and what device you are using

Version of URLImage library The version of the library where the bug happens.

Sample code ForEach(HomeModel.filtered){item in //Item View... //Text(item.item_name)

                            ZStack(alignment: Alignment(horizontal: .center, vertical: .top ), content: {

                 URLImage(url: URL(string: item.item_image)!,
                 content: { image in
                     image
                         .resizable()
                         .aspectRatio(contentMode: .fill)
                        .frame(width:screen.width - 30, height: 250)
                 })
            .frame(width: screen.width - 30, height: 250)

Additional information: Screenshot 2020-11-12 at 8 23 08 AM

dmytro-anokhin commented 3 years ago

Hey, I can not reproduce the issue from the description, and the sample code doesn't compile. Please try isolating the issue in a sample view that can be compiled without dependencies other than the URLImage package.

NoahKamara commented 3 years ago

Try using the .clipped() modifier when using .fill in aspectRatio

I found my solution on Stackoverflow

dmytro-anokhin commented 3 years ago

I'm closing the issue assuming that the solution suggested by @noahkamara fixes the problem.