-1

如何修复相对于主视图的 VStack,这意味着即使页面滚动,它也始终保持在同一个位置。我尝试过使用叠加层、ZStack 等。但是,我没有太多运气。下图显示了我想在 SwiftUI 中执行的操作的示例

吨

4

1 回答 1

0

我相信这就是你想要做的:

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)
            )
        }
    }
}
于 2020-08-27T07:21:57.033 回答