I have two UIImageView
s, 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
?
I have two UIImageView
s, 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
?
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 containerUIView
, and turn that view'sclipsToBounds
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.