如何解决相对于主视图修复VStack,以便即使滚动页面也可以将其保持在同一位置
如何相对于主视图修复VStack,这意味着即使滚动页面,它也始终位于同一位置。我曾尝试使用叠加层,ZStack等。但是,我没有那么幸运。下图显示了我要在SwiftUI中执行的操作的示例
解决方法
我相信这就是您想要做的:
struct IntroView: View {
var body: some View {
VStack {
ScrollView {
Text("Apollo 1,initially designated AS-204,was the first crewed mission of the United States Apollo program,the project to land the first men on the Moon.\n\nPlanned as the first low Earth orbital test of the Apollo command and service module,to launch on February 21,1967,the mission never flew; a cabin fire during a launch rehearsal test at Cape Kennedy Air Force Station Launch Complex 34 on January 27 killed all three crew members—Command Pilot Virgil I. \"Gus\" Grissom,Senior Pilot Ed White,and Pilot Roger B. Chaffee—and destroyed the command module (CM).\n\nThe name Apollo 1,chosen by the crew,was made official by NASA in their honor after the fire.\n\nApollo 7 was an October 1968 human spaceflight mission carried out by the United States. It was the first mission in the United States' Apollo program to carry a crew into space. It was also the first U.S. spaceflight to carry astronauts since the flight of Gemini XII in November 1966.\n\nThe AS-204 mission,also known as \"Apollo 1\",was intended to be the first crewed flight of the Apollo program. It was scheduled to launch in February 1967,but a fire in the cabin during a January 1967 test killed the crew.\n\nCrewed flights were then suspended for 21 months,while the cause of the accident was investigated and improvements made to the spacecraft and safety procedures,and uncrewed test flights of the Saturn V rocket and Apollo Lunar Module were made. Apollo 7 fulfilled Apollo 1's mission of testing the Apollo command and service module (CSM) in low Earth orbit.")
.font(.title)
}
.overlay(
Text("Mission Description")
.font(.largeTitle)
.padding(10)
.background(Color.blue)
)
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。