giraffeee.dev
  • Home
Sign in Subscribe

SwiftUI

A collection of 1 post
How to center a viewAligned ScrollView in SwiftUI
SwiftUI

How to center a viewAligned ScrollView in SwiftUI

By default a ScrollView with  .scrollTargetBehavior(.viewAligned) is aligned to the leading edge. To get a .viewAligned ScrollView centered, you can use combination of .containerRelativeFrame, constant spacing, and optionally .contentMargins and .safeAreaPadding.
17 Nov 2024 2 min read
Page 1 of 1
giraffeee.dev © 2025
  • Sign up
Powered by Ghost