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

URLImage not working inside Button #83

Closed 0radek closed 4 years ago

0radek commented 4 years ago

Summary and/or background Using URLImage inside Button does not work, unless renderingMode is provided. If I use URLImage anywhere else, works just great!

I am wondering if this is working as intended.

OS and what device you are using ios 13, iphone 7

Version of URLImage library

What you expected would happen Image would load

What actually happens Doesn't show anything, in my case just a circle button with a background. No image at all.

Sample code

HStack() {
    Spacer()
    VStack(alignment: .trailing) {
        Button(action: {
            print("Profile Button Clicked")
        }) {
            URLImage(profileImageUrl!) { proxy in
                proxy.image
                    .renderingMode(.original) // <- have to add this in order to see the image
                    .resizable()            
                    .aspectRatio(contentMode: .fill) 
                    .clipped()                     
            }
                .frame(width: 56, height: 56)  
                .cornerRadius(28)
        }
    }
}

Test data

https://static.toiimg.com/thumb/msid-67586673,width-800,height-600,resizemode-75,imgsize-3918697,pt-32,y_pad-40/67586673.jpg

dmytro-anokhin commented 4 years ago

Hey,

thank you for the sample code.

This issue is not a bug. I assume you use this code in the navigation bar or other system element that forces renderingMode to template. I see this reports a lot, but this is system behaviour - you can try with regular image.

Only thing you can do is to submit feedback to SwiftUI team at Apple 🙂 Maybe with enough reports they will revisit this.

0radek commented 4 years ago

Ah okay! Thanks for the response, my apologies I'm new to swift/ios and was unsure.