TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Infinite scrollable Canvas on macOS?

Forums > SwiftUI

I'm working on a little vector drawing application for macOS, written in SwiftUI. After experimenting with Path, Shape and Canvas, I've decided Canvas is the way to go for this. I’ve got a basic window with a scrolling canvas in it:

Scrolling Canvas

But it has some issues, the first of which: how can I simulate an infinite grid? In the past, I would just draw my scroll view’s content by looking at the visible bounds and filling the window. But if the window is enlarged to be bigger than the Canvas’s size, the scroll bars disappear and the Canvas is centered. I’ve tried setting its frame to maxWidth: .infinity, but that doesn't have any effect. Moreover, drawing outside the Canvas is clipped.

I wanted for my logical canvas's bounds to grow as new objects were created, always being slight larger than the encompassing rectangle. I’m not sure how to accomplish that in SwiftUI.

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.