Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 258
Concuror Avatar asked Jan 16 '23 18:01

Concuror


2 Answers

You need to set clipsToBounds property of the UIImageView to YES.

like image 59
rishi Avatar answered Jan 29 '23 05:01

rishi


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

like image 34
Concuror Avatar answered Jan 29 '23 03:01

Concuror