Post

Replies

Boosts

Views

Activity

SwiftUI LazyVGrid Positioning
Hello, I want to create a dashboard with LazyVGrid. I made a lineup like 2-2-1. It's okay as the images in the first 2 rows are the same, but I can't fit last image exactly because the bottom image is bigger than the others. I am attaching a screenshot for your better understanding. How can I center currency converter image overflowing from the screen? struct ContentView: View {   let columns = [     GridItem(.fixed(150), spacing: 30),     GridItem(.fixed(150), spacing: 30),]   var body: some View {         NavigationView{       LazyVGrid(columns: columns) {                   // WEIGHT * MASS         NavigationLink(destination: UnitView()) {           Image(systemName: "scalemass")             .font(.system(size: 60))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.purple.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Weight")               .foregroundColor(.black)               .padding()               .font(.system(size: 22)),                  alignment: .bottom )}                             //DISTANCE *         NavigationLink(destination: DistanceView()) {           Image(systemName: "figure.walk")             .font(.system(size: 60))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.orange.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Distance")               .foregroundColor(.black)               .padding()               .font(.system(size: 22)),                  alignment: .bottom )}                                       //TEMPERATURE *         NavigationLink(destination: TemperatureView()) {           Image(systemName: "thermometer.sun")             .font(.system(size: 56))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.yellow.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Temperature")               .foregroundColor(.black)               .padding()               .font(.system(size: 21)),                  alignment: .bottom )}                             // TIME *         NavigationLink(destination: TimeView()) {           Image(systemName: "clock")             .font(.system(size: 60))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.blue.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Time")               .foregroundColor(.black)               .padding()               .font(.system(size: 21)),                  alignment: .bottom ) }                           //CurrencyView         NavigationLink(destination: CurrencyView()) {           Image(systemName: "dollarsign.square.fill")             .font(.system(size: 90))             .padding()             .frame(width: 350, height: 160, alignment: .top)             .background(Rectangle().fill(Color.green.opacity(0.4))             .shadow(radius: 10)).cornerRadius(20)             .foregroundColor(.white.opacity(0.9))             .overlay(Text("Currency Converter")               .foregroundColor(.black)               .padding()               .font(.system(size: 27)),                  alignment: .bottom )}                                                   }          }        }      }
2
0
4.4k
Apr ’23
SwiftUI LazyVGrid Positioning
Hello, I want to create a dashboard with LazyVGrid. I made a lineup like 2-2-1. It's okay as the images in the first 2 rows are the same, but I can't fit last image exactly because the bottom image is bigger than the others. I am attaching a screenshot for your better understanding. How can I center currency converter image overflowing from the screen? struct ContentView: View {   let columns = [     GridItem(.fixed(150), spacing: 30),     GridItem(.fixed(150), spacing: 30),]   var body: some View {         NavigationView{       LazyVGrid(columns: columns) {                   // WEIGHT * MASS         NavigationLink(destination: UnitView()) {           Image(systemName: "scalemass")             .font(.system(size: 60))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.purple.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Weight")               .foregroundColor(.black)               .padding()               .font(.system(size: 22)),                  alignment: .bottom )}                             //DISTANCE *         NavigationLink(destination: DistanceView()) {           Image(systemName: "figure.walk")             .font(.system(size: 60))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.orange.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Distance")               .foregroundColor(.black)               .padding()               .font(.system(size: 22)),                  alignment: .bottom )}                                       //TEMPERATURE *         NavigationLink(destination: TemperatureView()) {           Image(systemName: "thermometer.sun")             .font(.system(size: 56))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.yellow.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Temperature")               .foregroundColor(.black)               .padding()               .font(.system(size: 21)),                  alignment: .bottom )}                             // TIME *         NavigationLink(destination: TimeView()) {           Image(systemName: "clock")             .font(.system(size: 60))             .padding()             .frame(width: 150, height: 150, alignment: .center)             .background(Rectangle().fill(Color.blue.opacity(0.5))               .shadow(radius: 3)).cornerRadius(20)             .foregroundColor(.black)             .overlay(Text("Time")               .foregroundColor(.black)               .padding()               .font(.system(size: 21)),                  alignment: .bottom ) }                           //CurrencyView         NavigationLink(destination: CurrencyView()) {           Image(systemName: "dollarsign.square.fill")             .font(.system(size: 90))             .padding()             .frame(width: 350, height: 160, alignment: .top)             .background(Rectangle().fill(Color.green.opacity(0.4))             .shadow(radius: 10)).cornerRadius(20)             .foregroundColor(.white.opacity(0.9))             .overlay(Text("Currency Converter")               .foregroundColor(.black)               .padding()               .font(.system(size: 27)),                  alignment: .bottom )}                                                   }          }        }      }
Replies
2
Boosts
0
Views
4.4k
Activity
Apr ’23