Skip to content
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 goes out of bounds and does not respect frame(widht, height) #2164

Closed
vanniktech opened this issue Nov 5, 2023 · 2 comments
Closed

Comments

@vanniktech
Copy link

Using 7.10.0 I have the following code:

KFImage(URL(fileURLWithPath: flashcards.fileHandler.absolutePath(path: image.path())))
    .loadDiskFileSynchronously()
    .cacheMemoryOnly()
    .resizable()
    .aspectRatio(contentMode: .fill)
    .frame(width: size.width, height: size.height)

I have a fixed aspect ratio on the size and would like to have the image shown in the entire size and center it and cut off the trailing top / bottom. However, currently KFImage is just upsizing itself and then it looks like this:

IMG_CFA1CAA179F7-1

I only want to show the image portion where you can see the overlay. How can I achieve this? I'm somewhat certain I had this working properly in some earlier version of Kingfisher with the above code, but don't remember the version I had used at that time.

@onevcat
Copy link
Owner

onevcat commented Nov 13, 2023

Maybe you want to add a .clipped() after your frame?

@vanniktech
Copy link
Author

Huh that does the trick indeed. I thought I had tried this out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants