How to hide a KFImage when image loading fails? #2066
Closed
NoahKnudsen
started this conversation in
General
Replies: 1 comment
-
When loading fails, Kingfisher uses a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to achieve a layout whereby an image will be full width when it successfully loads and take up no space whatsoever when it fails. It's turned out to be tricker than I imagined.
Here is the basic setup. This code fails to load an image, and then produces a large red-bordered square as opposed to taking up no space.
I believe that KFImage is using an empty square image in the event of a failure, meaning that when I set
scaledToFit
andmaxWidth: .infinity
I end up with a big empty space in the layout.I have tried adding the modifier
onFailureImage(nil)
, and I have tried doing the scaling & resizing insidecontentConfigure
but it has no effect. The latter,contentConfigure
, always receives a non-optionalImage
anyway so that scuppers that idea!The only working solution I have come up with is to keep some additional local state in my view to manually hide the if it fails:
Is there a cleaner solution to this problem?
Beta Was this translation helpful? Give feedback.
All reactions