1

What is the best way, if you need a combination of contentModes in UIImageView?

Example: .scaleToFill + .top

SchmidtFx
  • 498
  • 4
  • 16
  • .scaleToFill + .top : Scale to fill will fill the whole area of the `UIImageView`, so there is no point in doing + .top on it. If it were .aspectFit + .top, that'd make sense. – Larme Feb 26 '18 at 09:49
  • No, .scaleToFill fills the image in the image frame from the "center-center" point. You can imagine it when you compare that with the `background-position` property in CSS. Here you can combine 2 instructions as well. Example: `background-position: center top;`. In my case: I have an image with a person. If I select `.scaleToFill` the `UIImageView` will be filled correctly, but the face gonna cut off. With the CSS property it would be possible to scaleFill it from the center-top point. The face would going to be visible. – SchmidtFx Feb 26 '18 at 12:16
  • @SchmidtFx did you find a solution to this? I need to do the same thing – Deveesh Jun 30 '21 at 13:23
  • @Deveesh A possible way is to use some third party library. Check out FaceAware, https://github.com/BeauNouvelle/FaceAware if it could solve your demand. – SchmidtFx Jul 01 '21 at 15:01

0 Answers0