Maskstobounds与clipstobounds [英] Maskstobounds vs clipstobounds

查看:493
本文介绍了Maskstobounds与clipstobounds的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为 clipstobounds maskstobounds 的工作相同。

我找不到他们之间有什么区别。

I couldn't find any difference between them.

有人会解释两者是如何不同的。

Somebody kindly explain how both are different.

推荐答案

masksToBounds


图层中任何超出其边界的子图层都将被剪裁到这些边界。在这种情况下,将层视为其子层的窗口;窗口边缘以外的任何东西都不可见。当masksToBounds为NO时,不会发生剪切。

Any sublayers of the layer that extend outside its boundaries will be clipped to those boundaries. Think of the layer, in that case, as a window onto its sublayers; anything outside the edges of the window will not be visible. When masksToBounds is NO, no clipping occurs.

当此属性的值为true时,Core Animation会创建一个与图层边界匹配的隐式剪切蒙版,包括任何角半径效应。如果还指定了mask属性的值,则将两个掩码相乘以获得最终的掩码值。

When the value of this property is true, Core Animation creates an implicit clipping mask that matches the bounds of the layer and includes any corner radius effects. If a value for the mask property is also specified, the two masks are multiplied to get the final mask value.

你可以得到有关 API参考的更多信息。

you can get the more information in API Reference.

clipToBounds


对于部分在...之外的子视图,clipsToBounds的用例更多主要观点。例如,我在其父(矩形)UIView的边缘有一个(圆形)子视图。如果将clipsToBounds设置为YES,则只显示一半圆/子视图。如果设置为NO,则整个圆圈将显示。刚刚遇到这个想要分享

The use case for clipsToBounds is more for subviews which are partially outside the main view. For example, I have a (circular) subview on the edge of its parent (rectangular) UIView. If you set clipsToBounds to YES, only half the circle/subview will be shown. If set to NO, the whole circle will show up. Just encountered this so wanted to share

了解更多信息示例链接

这篇关于Maskstobounds与clipstobounds的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆