UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Need help to create a "chess" background.

Forums > SwiftUI

Hi,

Can someone tell me or show me a code of how to create a chessbackground (gray and green color instead of black and white). I found a code that made whole background of iphone view to a chessbackground.

This is what i have now: https://ibb.co/cXbdD3B

This is the size i want it, but with same size on the squares as picture above https://ibb.co/RB5W8Zs

Also the code i found is this:



        ZStack {
          VStack(spacing: 0) {
            ForEach((1...10).reversed(), id: \.self) { i in
              HStack(spacing: 0) {
                ForEach((1...5).reversed(), id: \.self) { i in
                  Color.green
                  Color.gray
                }
              }
              HStack(spacing: 0) {
                ForEach((1...5).reversed(), id: \.self) { i in
                  Color.gray
                  Color.green
                }
              }
            }
          }.edgesIgnoringSafeArea(.all)
        }
    }
}

2      

You could look at this for some ideas Checkerboard

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.