텍스트를 통해 내 앱을 실행하기위한 지침을 표시하는 지침보기를 설정하려고합니다 (어떻게 작동하는지 잘 이해하지 못하고 단계별 지침이 필요한 사용자를 위해).
다음 코드를 작성했지만 실행했을 때이 특정 뷰를 열었을 때 매우 느리게 실행되었고 충돌없이 충돌하는 것과 같이 아무것도하지 않을 때까지 스크롤이 매우 느 렸습니다.
내 코드 :
NavigationView {
ScrollView {
LazyVStack(alignment: .leading) {
padding()
Text("Main Screen")
.font(.title2)
.foregroundColor(.purple)
Text("This is the description text for the Main Screen")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
}.padding(.leading)
LazyVStack(alignment: .leading) {
Text("Log In")
.font(.title2)
.foregroundColor(.purple)
Text("This is the description text for the Login")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
padding()
}.padding(.leading)
LazyVStack(alignment: .leading) {
Text("Workout")
.font(.title2)
.foregroundColor(.purple)
Text("This is the description text for Workouts.")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
padding()
}.padding(.leading)
LazyVStack(alignment: .leading) {
Text("Logout")
.font(.title2)
.foregroundColor(.purple)
Text("This is the description text for Logout")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
padding()
}
.padding(.leading)
LazyVStack(alignment: .leading) {
Text("Settings")
.font(.title2)
.foregroundColor(.purple)
Text("This is the description text for Settings")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
padding()
}
.padding(.leading)
}
.navigationTitle("Instructions")
}
내가 가진 코드는 위보다 '설명 텍스트'에 더 많은 코드가 있었고 각각의 새로운 카테고리 또는 제목은 위와 같이 2 개의 텍스트 세트가있는 새로운 LazyVStack 블록으로 구성되었습니다. 전체보기는 8-10 개의 LazyVStack 블록으로 구성되어야합니다.
아래는 내가하려는 작업의 다이어그램입니다.
기본적으로 제목과 그 아래에 제목에 대한 설명이있는 텍스트 만 포함하는 스크롤 가능한보기를 만들려고합니다. 최대 10 개의 제목과 설명이 있습니다 (모두 텍스트).
어떤 아이디어, 내가 뭘 잘못하고 있으며 어떻게 해결할 수 있습니까?
나는 당신 padding()
의 문제가 있다고 생각합니다 . 그들을 제거하십시오.
다음과 같이 뷰에 패딩을 추가해야합니다.
Text("content")
.padding()
당신은에서 볼 수있는 문서 , padding(_)
뷰 수정이며 호출해야한다 View
.
구성 요소 사이에 추가 공간을 추가하려면 다음 중 하나를 수행하십시오.
1- 다음 과 같이 LazyVStack
전달 하여 구성 요소 사이의 공간을 설정하십시오 spacing
.
LazyVStack(alignment: .leading, spacing: 32) { // <- spacing
Text("Main Screen")
.font(.title2)
.foregroundColor(.purple)
Text("This is the description text for the Main Screen")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
}.padding(.leading)
2- 또는 padding(_, _)
수정자를 사용하여 상단 패딩을 설정합니다 .
LazyVStack(alignment: .leading) {
Text("Main Screen")
.font(.title2)
.foregroundColor(.purple)
.padiing(.top, 32) // <-- padding
Text("This is the description text for the Main Screen")
.padding(.all)
.font(.title3)
.foregroundColor(.pink)
.padding(.top, 32) // <-- padding
}.padding(.leading)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다