ScrollView, SwiftUI, and ShapeEdit

Dmytro Anokhin
1 min readAug 18, 2021

--

ShapeEdit

Recently I was looking at ScrollView in SwiftUI. The big problem is that it’s very basic, and not in a good way. There is no APIs for interactions that we used to: precise magnification, autoscroll, etc.

Wrapping UIScrollView/NSScrollView is not a big problem and it works really nice. With exception of gestures on macOS, mouse and touch coordinates won’t translate properly when scroll view is magnified. That can be workaround using gesture recognizers (not SwiftUI ones).

So I tried to build an app around it.

Remember ShapeEdit, the app Apple used in “Document Based Apps” and “Stacks, Grids, and Outlines” sessions from WWDC? Here is my version: https://github.com/dmytro-anokhin/ShapeEdit

It uses the package I created to wrap UIScrollView/NSScrollView for SwiftUI: https://github.com/dmytro-anokhin/advanced-scrollview

If you building or considering to build something similar it might help. Hope in next SwiftUI iteration we’ll see improved ScrollView.

Cheers!

P.S. This is only a proof of concept, it’s rough on edges, but I still want to share it.

--

--

Dmytro Anokhin

iOS Developer, here to share best practices learned through my experience. You can find me on Twitter: https://twitter.com/dmytroanokhin