|
On Day 33, in the Animating with gestures video, Paul talks about using CGSize.zeo in a @State property called dragAmount but he doesn't really say why we're using it. He says it stands for Core Graphics which is an old Apple api and .zero represents no size, no width, no height. I can only assume from the code he produces that we're using CGSize because that's what DragGesture uses, but there really is no explanation. I've watched the video three times and I understand what he's doing but I have no idea what CGSize is. I looked in the Apple documentation but didn't really find anything helpful. Can anyone please provide a simple explanation? One of his code examples from the video is below:
|
|
The reason we use
So Though why Apple chose to use |
|
Thanks, for the responses. Basically, from what I understand, CGSize is a structure used for DragGestures(and possibly other things) for determining distance in 2d space and CGSize.zero is the start point. After reading the responses, I messed around with Xcode a little and ended up adding this to the HStack{} right before the getsture modifier to see how the values change.
|
|
Thanks for the clarification.
|
|
Well, no.
Those can and often do have the same numeric values, but those values do not represent the same thing. If you start with But if you start with So It's telling that Per Apple's docs:
For those who don't remember their geometry, Wikipedia's got you covered: "a translation is a geometric transformation that moves every point of a figure, shape or space by the same distance in a given direction." |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
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.