我正在尝试通过单击iOS 16中的按钮转到SwiftUi View File Home:
Sreen射击
我已经阅读了苹果的文档,并在谷歌和YouTube上进行了搜索,但我没有得到答案。
这是我的代码:
import SwiftUI import CoreData struct ContentView: View { var body: some View { VStack (alignment: .leading) { Text("Welcome To").font(.system(size: 45)).fontWeight(.heavy).foregroundColor(.primary) Text("Pumping Fitness").font(.system(size: 45)).fontWeight(.heavy).gradientForeground(colors: [.red, .yellow]) Spacer() VStack (alignment: .leading, spacing: 24) { HStack (alignment: .center, spacing: 20) { Image(systemName: "dumbbell.fill").resizable().frame(width: 40, height: 30).gradientForeground(colors: [.red, .orange]) VStack (alignment: .leading, spacing: 4) { Text("Track your workouts").bold().font(.system(size: 22)).padding(.top, 10.0) Text("Easily track your progress during you are working out").font(.subheadline).padding(.bottom, 10.0) } } HStack (alignment: .center, spacing: 20) { Image(systemName: "timer").resizable().frame(width: 40, height: 40).gradientForeground(colors: [.red, .orange]) VStack (alignment: .leading, spacing: 4) { Text("Auto rest timer").bold().font(.system(size: 22)) Text("Start your rest time with one single tap").font(.subheadline).padding(.bottom, 10.0) } } HStack (alignment: .center, spacing: 20) { Image(systemName: "figure.run").resizable().frame(width: 40, height: 50).gradientForeground(colors: [.red, .orange]) VStack (alignment: .leading, spacing: 4) { Text("Add your own exercises").bold().font(.system(size: 22)) Text("Create your own type of exercises at a glance").font(.subheadline) } } } Spacer() Spacer() //HStack creado para poder alinear el boton al centro. HStack(alignment: .center) { Button(action: {} ) { Text("Start Pumping").fontWeight(.black).foregroundColor(.white) } .padding() .frame(width: 280, height: 60) .background(LinearGradient(gradient: Gradient(colors: [Color.red, Color.yellow]), startPoint: .leading, endPoint: .trailing)) .cornerRadius(17) }.padding(.leading) }.padding(.all, 40) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } extension View { public func gradientForeground(colors: [Color]) -> some View { self.overlay(LinearGradient(gradient: .init(colors: colors), startPoint: .topLeading, endPoint: .topTrailing)) .mask(self) } }
你知道我怎么做吗?o查看了YouTube上的视频,但所有示例都有一个列表,我想显示这个“欢迎页面”,然后转到我的主页。