How do I fix a VStack relative to the main view, which means it always stays in the same place even if the page is scrolled. I have tried using overlays, ZStack and so on. However, I have not had much luck with it. The below image shows an example of what I want to do in SwiftUI
Asked
Active
Viewed 36 times
0
-
I don’t think you have done it properly with overlay – Aug 27 '20 at 07:24
1 Answers
0
I believe this is what you’re trying to do:
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)
)
}
}
}