SwiftUI Content Margins for Scroll Content Animation Bugs
Originator: | bryn.bodayle | ||
Number: | rdar://FB16829317 | Date Originated: | 3/11/25 |
Status: | Open | Resolved: | |
Product: | SwiftUI | Product Version: | iOS 18.4 Seed 2 |
Classification: | Bug | Reproducible: | Always |
There are three bugs with the new contentMargins API when using it with scroll content. The code below demonstrates them, and I've captured them in the video. 1. The content inset change is not animatable. 2. If you scroll down to a certain offset, LazyVStack items will fly in and off screen 3. If you scroll to another offset, LazyVStack items will disappear and reappear. struct ContentView: View { var body: some View { Button(action: { .opacity(0.5) showInset.toggle() } }, label: { Text("Toggle content inset") }) ScrollView { LazyVStack { ForEach(0..<20) { index in Text("Row: \(index)") .frame(height: 100) .background(index % 2 == 1 ? Color.red : Color.green) .opacity(0.5) } } } .contentMargins(.top, showInset ? 0 : 72, for: .scrollContent) } @State private var showInset: Bool = false } #Preview { ContentView() }
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at feedbackassistant.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!