Sets the transparency of the view.
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
A value between 0 (fully transparent) and 1 (fully opaque).
A view that sets the transparency of this view.
Apply opacity to reveal views that are behind another view or to de-emphasize a view.
When applying the
opacity(_:) modifier to a view that has already had its opacity transformed, the modifier multiplies the effect of the underlying opacity transformation.
The example below shows yellow and red rectangles configured to overlap. The top yellow rectangle has its opacity set to 50%, allowing the occluded portion of the bottom rectangle to be visible: