gpt4 book ai didi

swift - 将图像保持在不同 View 的同一位置

转载 作者:行者123 更新时间:2023-11-30 10:36:13 25 4
gpt4 key购买 nike

我正在尝试制作帐户注册系列页面,并且我希望我的应用程序图标(图像)在页面上保持相同的位置,但目前他们没有。

我尝试过使用垫片来使其均匀,但没有成功。

第一次观看:

 var body: some View {
NavigationView {
VStack {
VStack {
Image("logo")
.resizable()
.scaledToFit()

}

VStack {
InformationTextField(iconName: "person.fill", headlineText: "USERNAME", textFieldDescription: "Enter username here", protected: false)
InformationTextField(iconName: "lock.fill", headlineText: "PASSWORD", textFieldDescription: "Enter password here", protected: true)
NavigationLink(destination: Text(
"ee")) {
ActionButton(text: "signup")
}
Divider()
.background(Color("DividerColor"))
Text("Don't have an account?")
.fontWeight(.light)
NavigationLink(destination: SignupPage()) {
ActionButton(text: "sign up")
}

}


}
.padding()
}
}

第二个 View :

   var body: some View {
NavigationView {
VStack {
VStack {
Image("logo")
.resizable()
.scaledToFit()
}

VStack {
InformationTextField(iconName: "person.fill", headlineText: "USERNAME", textFieldDescription: "Enter username here", protected: false)
InformationTextField(iconName: "info.circle.fill", headlineText: "CONTACT", textFieldDescription: "Enter email or phone number here", protected: false)
InformationTextField(iconName: "calendar", headlineText: "AGE", textFieldDescription: "Enter birthday here", protected: false)
InformationTextField(iconName: "lock.fill", headlineText: "PASSWORD", textFieldDescription: "Enter password here", protected: true)
InformationTextField(iconName: "lock.fill", headlineText: "CONFIRM PASSWORD", textFieldDescription: "Re-enter password here", protected: true)
}
// .padding()
NavigationLink(destination: Text(
"ee")) {
ActionButton(text: "sign up")
}


}
.padding()
}
}

我希望 Logo 图像位于屏幕上完全相同的位置,无论 View 如何。我尝试过的一切都不起作用。

最佳答案

你可能应该尝试一下 ZStack

关于swift - 将图像保持在不同 View 的同一位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57965822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com