[英]Clip to bounds of a different UIImageView
I have two UIImageView
s, imageView1
and imageView2
. 我有两个
UIImageView
,分别为imageView1
和imageView2
。 I've set 我已经设定
self.imageView1.clipsToBounds = YES;
but I was wondering if it is possible to set imageView1
to clipToBounds
of imageView2
? 但我想知道是否有可能设置
imageView1
到clipToBounds
的imageView2
?
Not easily. 不容易。 The "right" way to do this would be to use a clipping path on the
imageView1
's layer. 做到这一点的“正确”方法是在
imageView1
的图层上使用剪切路径。 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. 把
imageView1
中心的容器内UIView
,并把这种观点的clipsToBounds
上。 Then: 然后:
If you're using Auto Layout, constrain the container view's size to be equal to the size of imageView2
. 如果您使用的是自动版式,则将容器视图的大小限制为等于
imageView2
的大小。
If you're not using Auto Layout, set the bounds of the container view to the size of imageView2
whenever you calculate layout. 如果你不使用自动布局,置容器中视图的边界,以规模
imageView2
当你计算布局。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.