Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

how to center vertically scrollview swiftui

/// Custom vertical scroll view with centered content vertically
///
struct VScrollView<Content>: View where Content: View {
  @ViewBuilder let content: Content
  
  var body: some View {
    GeometryReader { geometry in
      ScrollView(.vertical) {
        content
          .frame(width: geometry.size.width)
          .frame(minHeight: geometry.size.height)
      }
    }
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #center #vertically #scrollview #swiftui
ADD COMMENT
Topic
Name
4+2 =