|
Maybe I should just move along because the code is working but I have so many questions where I don't understand. So, objective is to just have an image rotating. Code I found informed me that .animation has been deprecated. So here's some stuff I discovered that doesn't make sense to me. This code works, but (1). why do I have to do onAppear? (without onAppear the image doesn't rotate).
Then, this is crazy to me, if I change the var to false and the isRotating to true it just reverses from clockwise to counter-clockwise. (2). I would think saying isRotating = false would mean No animation. Why does it reverse the direction? |
|
|
|
Thanks @nigelgee , this is helpful. Earlier today I had to comment out this code to make the animation work.
Now, for no reason I can deduce, both work. Is that just Xcode catching up? Or inevitable weirdness? My question in this case is basically, is the word Animation assumed in the second version of that line of code?
Anyway, I'm still confused, even after reading the page you shared, about why:
I just spent three hours reading https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID330 and https://docs.swift.org/swift-book/GuidedTour/GuidedTour.html and boy oh boy does it make me appreciate you and others who respond to my specific challenges on this journey. All the official docs, even from the first paragraph assume the reader is coming from a background knowing Objective C. If anyone knows a version of Swift and SwiftUI docs that assume zero Objective C background, I'd love to know about that! Thanks. |
|
Another question, after some research, it seems I can't apply a .rotationEffect to a View like my ZStack here. Is that true? If so, will that help me understand Views or modifiers better?
in the above case, the image does not rotate. I guess my question is how would I know what can and can't be modified by this modifier and what other modifiers are in the same category (not modifying)? |
|
Gabe, do you understand what this part means? isRotating ? 360 : 0 If not, review https://www.hackingwithswift.com/sixty/3/7/the-ternary-operator followed by https://www.hackingwithswift.com/books/ios-swiftui/conditional-modifiers Once you understand that, you'll understand why it's rotating that way. |
|
Holy wow. Thank you for you sharing those two links. When you put it that way it's totally obvious. But then I get stuck in tutorials differentiating Swift commands versus variables or other things that I name myself. The variable being In fact, isRotating is boolean, on or off. When it's on (true) the image goes to 360 degrees, and when it's off (false) it goes to 0 degrees. It just seems like |
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 October 1st.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.