如今SwiftUI如日中天,很是流行。当然,也确实好用。语法糖真甜! 照着官方的教程来: https://developer.apple.com/tutorials/swiftui/creating-and-combining-views
import SwiftUI
@main
struct Lesson1App: App {
var body: some Scene {
WindowGroup {
MainView()
}
}
}
import SwiftUI
struct MainView: View {
var body: some View {
VStack {
ZStack {
MapView().frame(height: 300).ignoresSafeArea(edges: .top)
Text("Here!").bold().font(.title).foregroundColor(.red).padding()
}
CircleImage().offset(y: -130).padding(.bottom, -130)
VStack (alignment: .leading)
{
Text("Turtle Rock").bold().foregroundColor(.green).font(.title)
HStack
{
Text("Joshua Tree National Park").font(.subheadline)
Spacer()
Text("HanZhou").font(.subheadline).padding(.trailing)
}
.font(.subheadline)
.foregroundColor(.secondary)
Divider()
Text("About Turtile Rock").font(.title2)
Text("Descriptive text goes here")
}
.padding()
Spacer()
}
}
}
最终效果如下:
|