Updated for Xcode 12.0
Any SwiftUI view can be partially or wholly transparent using the
opacity() modifier. This accepts a value between 0 (completely invisible) and 1 (fully opaque), just like the
alpha property of
UIView in UIKit.
For example, this creates a text view with a red background, then gives it 30% opacity:
Text("Now you see me") .padding() .background(Color.red) .opacity(0.3)
SPONSORED Are you tired of wasting time debugging your Swift app? Instabug’s SDK is here to help you minimize debugging time by providing you with complete device details, network logs, and reproduction steps with every bug report. All data is attached automatically, and it only takes a line of code to setup. Start your free trial now and get 3 months off exclusively for the Hacking with Swift Community.
Link copied to your pasteboard.