Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

XCode Canvas not showing me the entire page and just segments

Here is my code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Apps")
            .font(.system(size: 30))
            .fontWeight(.bold)
        Image("utm")
            .resizable()
            .frame(width: 60, height: 60)
        Text("UTM")
            .fontWeight(.bold)
        Text("Virtual machines for macOS")
            .foregroundColor(.gray)
        Button("Get UTM") {
            
        }
            .background(Color(hue: 0.0, saturation: 0.861, brightness: 1.0))
            .controlSize(.large)
            .cornerRadius(25)
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

And when I open canvas, this happens:

How do I turn it into 1 single content view instead of all of the segments being split up?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is because you need to use a stack like this

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Apps")
                .font(.system(size: 30))
                .fontWeight(.bold)
            Image("utm")
                .resizable()
                .frame(width: 60, height: 60)
            Text("UTM")
                .fontWeight(.bold)
            Text("Virtual machines for macOS")
                .foregroundColor(.gray)
            Button("Get UTM") {
                
            }
                .background(Color(hue: 0.0, saturation: 0.861, brightness: 1.0))
                .controlSize(.large)
                .cornerRadius(25)
        }
        
    }
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading