I have two requirements with ScrollView in SwiftUI.
-
Ability to zoom in/out subviews in the
ScrollView
while keeping the point of zoom stationary.UIScrollView
in UIKit haszoomScale
which seems absent in SwiftUI. The MagnifyGesture in SwiftUI doesn’t seem to provide this as the point of pan/zoom is not stationary with it. -
Ability to long press subview and drag it to another place in
ScrollView
. If the user keeps holding finger and drags subview near edges of theScrollView
frame, keep scrolling the scroll view in the direction of drag. If the user drags the subview outside of frame ofScrollView
, it gets removed from view hierarchy.
These things are not difficult in UIKit, it seems not straightforward in SwiftUI. How can I achieve these in pure SwiftUI way?