Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SwiftUI
- struct ContentView: View {
- @State private var bounds: Bounds = .zero
- var body: some View {
- VStack {
- controls
- scrollArea
- }
- }
- private var controls: some View {
- HStack {
- Text(verbatim: "\(bounds)")
- Spacer()
- Button("-100") {
- withAnimation {
- self.bounds.origin.y -= 100
- }
- }
- }
- }
- private var scrollArea: some View {
- ScrollArea(bounds: $bounds) {
- VStack {
- ForEach(0..<50) { item in
- self.row(for: item)
- }
- }
- }
- }
- private func row(for item: Int) -> some View {
- HStack {
- Text("Item: \(item)")
- .padding([.leading, .trailing])
- .background(Color.blue)
- Spacer()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement