Questions tagged [swiftui-scrollview]

For questions about ScrollView - a view in Apple's SwiftUI framework that is scrollable. When using this tag also include the more generic [swiftui] tag where possible.

Links:

127 questions
63
votes
7 answers

SwiftUI: Putting a LazyVStack or LazyHStack in a ScrollView causes stuttering (Apple bug??)

XCode Version 12.4 (12D4e) I have encountered this every time I have implemented a Lazy stack within a ScrollView: Add a LazyHStack to a horizontal ScrollView or a LazyVStack to a vertical ScrollView Add enough content such that the content size of…
chrysb
  • 1,351
  • 2
  • 13
  • 20
12
votes
4 answers

ScrollViewReader scrollTo with .center anchor bug?

So I'm try to use ScrollViewReader to programmatically scroll a horizontal scroll view. I thought it would work like scrollToItem with .centeredHorizontally in UIKit, and for the most part it does, but the last few elements in the scroll view are…
user1877760
  • 263
  • 2
  • 9
10
votes
0 answers

How to use TabView or ScrollView for carousel?

I'm trying to create a carousel like some of Apple's apps. The TabView has the paged style but it doesn't "peek" at the previous and next elements. The ScrollView(.horizontal) doesn't snap. I'm hoping for a mixture of the two behaviours without…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
9
votes
1 answer

Issue using matchedGeometryEffect animation in ScrollView

Animating Views between a LazyVGrid and an HStack with another view in between them (in this case, a Button), using matchedGeometryEffect, works great: Note how the animating views move above the Done button. However, when the views are contained…
Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
8
votes
0 answers

SwiftUI ScrollView scrolls too far when using scrollViewReader

I'm creating an app where I'm presenting data in paged views and each view contains a vertical scrollable list, enabled by scrollView. I'm also using scrollViewReader to be able to programmatically scroll to a specific position in the list. This…
skegget
  • 111
  • 1
  • 7
8
votes
1 answer

TabView with PageTabViewStyle() not using available height in ScrollView

so I have a TabView like shown below, but when I try to implement it in a ScrollView I always have to give it a fixed height. Is there a way of telling the tabview to use the space it needs in the scrollView? I don't know the height of the inner…
Paul
  • 153
  • 7
8
votes
4 answers

SwiftUI ScrollView does not center content when content fits scrollview bounds

I'm trying to have the content inside a ScrollView be centered when that content is small enough to not require scrolling, but instead it aligns to the top. Is this a bug or I'm missing adding something? Using Xcode 11.4 (11E146) @State…
andrewz
  • 4,729
  • 5
  • 49
  • 67
5
votes
1 answer

Scroll View Items Come Over the Navigation Bar in SwiftUI

I am new to SwiftUI. I made a custom nav bar. and added a scroll view below it. The problem I am getting is when I scroll down, the data inside scroll view comes over the navigation bar. Here is the screenshot: My code is: struct NewsfeedView: View…
5
votes
5 answers

SwiftUI: ScrollView that drags bottom sheet with it

I'm trying to create a SwiftUI Scrollview that drags its container like this: https://drive.google.com/file/d/1O92DgsVI1OjM1HEUXUwVywB8gcdShOP-/view?usp=sharing Many Apple apps use this (Apple Maps, Music, Wallet, etc) but I haven't found an easy…
blrsk
  • 185
  • 1
  • 4
  • 11
4
votes
2 answers

SwiftUI - Calculate height for long GeometryReader inside ScrollView

Based off of this question: SwiftUI - Drawing (curved) paths between views I draw the needed views and paths using the GeometryReader. The problem is, now it becomes too long for the screen to show it all (there are 15 such views but you can only…
Big_Chair
  • 2,781
  • 3
  • 31
  • 58
4
votes
1 answer

Resetting ScrollView position to the top of the page

I'm trying to make the scroll reset to the top of the page when a view appears (e.g. when you navigate back from a navigation link). The ScrollView is embedded within a NavigationView with a large title. Using the code below, I'm able to reset the…
sia
  • 256
  • 3
  • 14
4
votes
1 answer

Save ScrollViews position and scroll back to it later (offset to position)

I have found a way to save a ScrollViews offset with a GeometryReader and a PreferenceKey. SwiftUI | Get current scroll position from ScrollView And the ScrollViewReader has a method scrollTo to scroll to a set position. scrollTo The problem is,…
L3n95
  • 1,505
  • 3
  • 25
  • 49
4
votes
2 answers

SwiftUI: horizontal ScrollView inside NavigationLink breaks navigation

I want to use a simple horizontal ScrollView as NavigationLink inside a List. However, tapping on the ScrollView is not registered by a NavigationLink and therefore does not navigate to the destination. NavigationView { List { …
damirstuhec
  • 6,069
  • 1
  • 22
  • 39
3
votes
1 answer

Navigationbar title is inline on pushed view, but was set to large

I want a large title in the navigationbar on a pushed view in SwiftUI and an inline title on the parent view. When the parent navigation bar display mode is not set, it works: Working without display mode on parent But when I set the display mode in…
3
votes
0 answers

How to make ScrollView refreshable swiftui?

With Swiftui 3 Apple added modifier refreshable. I can use it with List. But if I have scrollview it doesn't work. Any ideas? ScrollView(.vertical) { LazyVGrid(columns: columns, spacing: gridSpacing) { ForEach($products, id:…
1
2 3
8 9