【发布时间】:2021-04-02 17:36:38
【问题描述】:
我正在构建一个应用程序,而且我是 SwiftUI 的初学者,所以这就是我遇到的问题。 我需要一个首先显示的登录页面,并且我已经为其创建了一个视图,您可以查看它。
struct LandingView: View {
var body: some View {
NavigationView{
VStack(alignment: .center){
Image("exxxlogo")
Spacer()
Text("Welcome")
.font(.system(size: 38))
.fontWeight(.bold)
.padding(.horizontal, 40)
.multilineTextAlignment(.center)
.foregroundColor(Color.white)
Text("Click below to continue to the app")
.font(.system(size: 16))
.padding(.horizontal, 20)
.multilineTextAlignment(.center)
.foregroundColor(Color.white)
.padding(.bottom, 35)
NavigationLink(destination: HomeView()){
Text("CONTINUE ")
.frame(width: 250, height: 50, alignment: .center)
.background(Color.red)
.foregroundColor(Color.white)
}
}
.background(
Image("backgroundlanding")
.frame(maxWidth: .infinity,maxHeight: .infinity)
.aspectRatio(contentMode: .fill)
.edgesIgnoringSafeArea(.top)
.edgesIgnoringSafeArea(.bottom)
)
}
我还为 tabview 创建了视图,以将它们重定向到 Home、Shop 等 我已经对我的 Contentview 做了这个
TabView {
HomeView()
.tabItem{
Image(systemName: "house")
Text("Home")
}
GamesView()
.tabItem{
Image(systemName: "gamecontroller")
Text("Games")
}
ShopView()
.tabItem{
Image(systemName: "bag")
Text("Shop")
}
MoreView()
.tabItem{
Image(systemName: "gear")
Text("More")
}.accentColor(.red)
并在主 app.swift 文件中将窗口组更改为landingview,以便它首先弹出。 但问题是当您单击landingview 中的按钮时,navigationlink 会将您重定向到主视图,但下面没有标签视图,只是空白
【问题讨论】: