Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Similar behavior to Aspect Fill but use the top part of the image

I'm using the content mode Aspect Fill for my UIImageView, and its working the way I want it for the most part. What I'm noticing is that it looks like it uses the middle section of the image as the part that it crops to make it fill the bounds. How can I do aspect fill, but have it use the top portion of the image?

like image 517
codeman Avatar asked Dec 09 '14 18:12

codeman


1 Answers

You can do this using the subclass UIImageViewAligned as long as the picture you are using is taller than it wide.

Here we have a base image where height > width

Base Image

Using this image in the example project with regular aspect fill

Aspect Fill

And aspect fill top

enter image description here

like image 189
Kevin Avatar answered Nov 12 '22 09:11

Kevin