ios – SwiftUI zoom and drag subview in ScrollView


I have two requirements with ScrollView in SwiftUI.

  1. Ability to zoom in/out subviews in the ScrollView while keeping the point of zoom stationary. UIScrollView in UIKit has zoomScale 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.

  2. 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 the ScrollView frame, keep scrolling the scroll view in the direction of drag. If the user drags the subview outside of frame of ScrollView, 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?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img