NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

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)
        }
    }
}

   

You could look at this for some ideas Checkerboard

   

Hacking with Swift is sponsored by Instabug

SPONSORED Catch bugs as soon as they happen and know exactly why a crash occurred. Instabug's SDK grabs all the logs they need to fix bugs, crashes and performance issues in minutes instead of days. Get screenshots, device details, network logs, repro steps, and tons of other critical insights needed to resolve issues and prioritize product backlogs straight from your dashboard. It only takes a minute to integrate!

Get started now

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

Reply to this topic…

You need to create an account or log in to reply.

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.