SwiftUI入门 day1

2025-03-05  本文已影响0人  LV大树

sample 1

swiftUI 1

code as follow:

struct ContentView: View {
    var body: some View {
        VStack {
            Spacer()
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.red)
            Spacer()
            Text("Hello, world! for SWiftUI ,start today at 2025.3.5")
            Spacer()
            Text("again")
            Spacer()
            HStack(alignment: .top, content: {
                Text("who are u")
                Text("can dare to beat me")
                Text("if you can't learn this skill quickly,you will lose in the future")
            })
            Spacer()
            HStack(alignment: .bottom) {
                Text("who are u")
                Text("can dare to beat me")
                Text("if you can't learn this skill quickly,you will lose in the future")
            }
            Spacer()
        }
        .padding(30)
        
        
    }
}

#Preview {
    ContentView()
}

sample 2

swiftUI 2

code as follow:


import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 10) {
            Spacer()
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.red)
            Spacer()
            Text("Hello, world! for SWiftUI ,start today at 2025.3.5")
            Spacer()
            Text("again")
            Spacer()
            HStack(alignment: .top, content: {
                Text("who are u")
                Text("can dare to beat me")
                Text("if you can't learn this skill quickly,you will lose in the future")
            })
            Spacer()
            HStack(alignment: .bottom,spacing: 30) {
                Text("who are u")
                Text("can dare to beat me")
                Text("if you can't learn this skill quickly,you will lose in the future")
            }
            Spacer()
        }
        .padding(20)
        
        
    }
}

#Preview {
    ContentView()
}

上一篇 下一篇

猜你喜欢

热点阅读