|
I would like to implement zoom behaviour using SwiftUI. Where should I call Edit: Updated title |
|
@Obelix, sorry, should have been more clearer. It's not about image zooming but rather window zooming for changing the window size in accordance with the window contents. When pressing the green window button with option key held, the window size should increase/decrease. |
|
That behavior is provided automatically. The programmer doesn't need to implement any methods. If I create a macOS project, I don't have to do anything and all three buttons just work out of the box. Where are you having an issue? |
|
roosterboy, indeed you are right. I am playing with a basic application draft, and after removing some unnecessary constraints I was able to get a behaviour that did not maximise the window, but kept it within the set boundaries. However, I could still use your advice. Right now, I am using a fixed value for my minimum root size, say 300-300, and it correctly switches between the minimum window size and the frame size for the child view. But if I remove all My question is, what is the best practice to make the zoomed size always the size of the child view? I used Sample code below:
Above code crashes, BTW. :D |
|
I think I spoke too soon about getting rid of
I'll update if I find a solution. |
|
I couldn't find a way to fix it. Can someone have a look at the code below:
Basically, the zoom behaviour should always return to below state: I will appreciate any possible help. It looks like this should be the textbook zoom behaviour, but for some reason it does not work. |
|
I figured out how to switch between sizes.
I will now try to figure out how to pass SwiftUI constrains to this function. |
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.
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.