1

I have two UIImageViews, imageView1 and imageView2. I've set

self.imageView1.clipsToBounds = YES;

but I was wondering if it is possible to set imageView1 to clipToBounds of imageView2?

Azat
  • 6,745
  • 5
  • 31
  • 48
burrGGG
  • 617
  • 2
  • 9
  • 18

1 Answers1

1

Not easily. The "right" way to do this would be to use a clipping path on the imageView1's layer. However, you can get the same effect much more easily as follows.

Put imageView1 centered inside a container UIView, and turn that view's clipsToBounds on. Then:

  • If you're using Auto Layout, constrain the container view's size to be equal to the size of imageView2.

  • If you're not using Auto Layout, set the bounds of the container view to the size of imageView2 whenever you calculate layout.

ravron
  • 11,014
  • 2
  • 39
  • 66