Sets the transparency of a view, where 0 is fully transparent and 1 is fully opaque.
97.2% of iOS users can use this modifier
iOS 13+ required
.opacity(_:) Sets the opacity value from 0.0 to 1.0
opacity: DoubleMake a view 50% transparent
Text("Hello, World!")
.padding()
.background(.blue)
.opacity(0.5)Animate opacity for fade in/out
@State private var isVisible = false
Text("Hello, World!")
.opacity(isVisible ? 1.0 : 0.0)
.animation(.easeInOut, value: isVisible)Loading related modifiers...
The .opacity() modifier requires iOS 13 or later. This means 97.2% of current iOS users can use this modifier.
Apply the .opacity() modifier to any SwiftUI view. Check the code examples above for usage patterns.
Visit the official Apple documentation for detailed information.