[SwiftUI] ScrollViewReader proxy의 scrollTo에서 위치 조정하기
https://developer.apple.com/documentation/swiftui/scrollviewproxy/scrollto(_:anchor:) ScrollViewReader를 이용해 proxy.scrollTo(id, anchor)를 이용하면 지정한 id의 뷰로 스크롤되어 이동할 수 있다. func scrollTo( _ id: ID, anchor: UnitPoint? = nil ) where ID : Hashable ScrollViewReader { proxy in ScrollView { Foreach(contents) { content in ExampleView() .id(content.id) } } } Button("이동") { proxy.scrollTo(이동하고싶은id, anchor: .l..
iOS
2023. 10. 17. 12:42