← back to the blog


Background image with Swift UI

Posted on December 15th, 2019 by George

 

Quite a simple process.

First, add the image to the Assets.xcassets folder. The image name without the extension will be used later as a reference!

Now in your view add a ZStack entry point where the image for the background will be used. Then the nested elements, the rest of the application.

 

    var body: some View {
        ZStack {

            Image("bgimage")

            VStack {

                Text("\("Test Text".uppercased())")
                    .font(.custom( "Gill Sans", size: 36))
                    .foregroundColor(Color(.blue))
            
                
            }
        }
        
    }
}

 

Thank you!