The Mask modifier in SwiftUI is used to hide part of your view. It takes the invisible portion of one view and apply it to another.
The Mask modifier in SwiftUI is used to hide part of your view. It takes the invisible portion of one view and apply it to another.
Then apply the background() modifier and change its color to red.
To apply a mask, open the XCode library and search for Mask in the modifier menu.
Drag and drop it at the end of the view you want to mask.
It takes in a view that you want to use to apply its alpha content. This can be an image with alpha channels such as a PNG file or it can be one of the built-in shapes in SwiftUI.
Using an Image
To use an image, locate a PNG file on your computer and drag it into the “Assets” folder.
If we look at the preview, the invisible portion of the image is applied to the Text view.
Using Built-in Shapes
Some common shapes in SwiftUI is the