How to create a color with an alpha value using SwiftUI?

In SwiftUI there is one specific modifier called opacity that can be use to change the alpha level of any colors

Text("Hello world").background(Color.black.opacity(0.8)) // Set the background color as partially transparent.

Additionally the same modifier can be applied to any view, to change its alpha.

Image("myImage").opacity(0.8) //The image will be partially transparent

Leave a Comment

error code: 521