---
title: mask
framework: quartzcore
role: symbol
role_heading: Instance Property
path: quartzcore/calayer/mask
---

# mask

An optional layer whose alpha channel is used to mask the layer’s content.

## Declaration

```swift
var mask: CALayer? { get set }
```

## Discussion

Discussion The layer’s alpha channel determines how much of the layer’s content and background shows through. Fully or partially opaque pixels allow the underlying content to show through, but fully transparent pixels block that content. The default value of this property is nil. When configuring a mask, remember to set the size and position of the mask layer to ensure it is aligned properly with the layer it masks. Special Considerations The layer you assign to this property must not have a superlayer. If it does, the behavior is undefined.

## See Also

### Modifying the layer’s appearance

- [contentsGravity](quartzcore/calayer/contentsgravity.md)
- [Contents Gravity Values](quartzcore/contents-gravity-values.md)
- [opacity](quartzcore/calayer/opacity.md)
- [isHidden](quartzcore/calayer/ishidden.md)
- [masksToBounds](quartzcore/calayer/maskstobounds.md)
- [isDoubleSided](quartzcore/calayer/isdoublesided.md)
- [cornerRadius](quartzcore/calayer/cornerradius.md)
- [maskedCorners](quartzcore/calayer/maskedcorners.md)
- [CACornerMask](quartzcore/cacornermask.md)
- [borderWidth](quartzcore/calayer/borderwidth.md)
- [borderColor](quartzcore/calayer/bordercolor.md)
- [backgroundColor](quartzcore/calayer/backgroundcolor.md)
- [shadowOpacity](quartzcore/calayer/shadowopacity.md)
- [shadowRadius](quartzcore/calayer/shadowradius.md)
- [shadowOffset](quartzcore/calayer/shadowoffset.md)
