-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KFImage doesn't allow to configure Image as a View (SwiftUI) #2016
Comments
Basically, when using a placeholder, Kingfisher wraps it in a ZStack {
Image(systemName: "arrow.triangle.2.circlepath")
.resizable()
.scaledToFit()
}
.scaledToFill()
.frame(width: 200, height: 100)
.clipped() So the issue here comes from the way SwiftUI calculate its child view size. As an image it will just ignore the proposal size when a clip applies outside. Maybe you can try to also pass in the size to the placeholder, like this: ZStack {
Image(systemName: "arrow.triangle.2.circlepath")
.resizable()
.scaledToFit()
.frame(width: 200, height: 100)
}
.scaledToFill()
.frame(width: 200, height: 100)
.clipped() So in your example, try: KFImage(url)
.resizable()
- .configure({ image in
- image
- //.scaledToFill() // ⛔️ NOT ALLOWED
- })
.placeholder {
Image(systemName: "arrow.triangle.2.circlepath")
.resizable()
.scaledToFit()
+ .frame(width: 200, height: 100)
}
.scaledToFill()
.frame(width: 200, height: 100)
.clipped() I will also see if it is possible to provide a more generic |
Indeed, it works perfectly if I pass the size as you suggested 🎉 I let you close that issue if needed (or maybe we keep it open for that |
Please allow me to close it for now. : ] Ref: #2027 |
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Issue Description
What
I want to apply a
scaledToFill()
modifier to the loadedImage
and ascaledToFit()
to the placeholderView
but it is not possible because theKFImage.configure
function requires to return anImage
instead of aView
.(Where
HoldingView
is anImage
forKFImage
)If we take the
AsyncImage
as an example, it allows to configure theImage
and returns someView
insteadReproduce
Here is a code that reproduce the issue:
Other Comment
I am working on a project that support iOS 14+
The text was updated successfully, but these errors were encountered: