Search code examples
iosuiimageviewuiimagecontentmode

How to make content non visible outside UIView


I have an UIImageView with UIViewContentModeCenter, so Images that it holds are not getting scaled or deformed. But this way if the image is larger, it can be seen outside the ImageView's frame. I don't want to crop the image (user can scale it, so the loss of data is not an option), but I need to make the part of it outside of ImageView invisible or something


Solution

  • My solution was to put UIImageView inside UIScrollView and then manage size and position things inside scrollView.