var mask of UIView

Can you tell me where to find some useful examples of the use of the var mask of UIView?

Thanks

Carlo1850

Replies

The mask property is used to control which portion of a view's content is visible and which portions are "masked out". You can picture the effect if you imagine holding a paper cut-out in front of you and looking through the cut away portion of the paper.

Note that the color of the mask view doesn't matter. It's the alpha channel that determines what portions of the view's content shows through. Unlike the paper cut-out example above, it's the opaque pixels of the mask that allow the content to show through and the transparent pixels that block the content.

Two examples of what you might want to use this for are:
  1. to show an image or gradient within the letters of a piece of text

  2. to have a view's content gradually fade out by masking it with a gradient from a solid color to a clear color.

If you need more examples, the result of an image search for "clipping mask" should mostly be examples of this effect and not too many pictures of real-world masks that go on people's faces.