|
Attempting to have a background with a gradient that animates. The background pops up, but the animation does not trigger. Very curious what is happening to cause the animation to not trigger. Thanks in advance for the help!
|
|
@Swink gets animated about a view problem:
Somewhere in these archives, I wrote a small piece about eating an elephant. See -> Eating an Elephant How does this relate to your troubles? You might have too many bites on your plate. It's difficult to chew what you have with so much more in the way. One Bite at a TimeClear some things off your plate and think about animating just the background. That's what I did in the code below. I thought about a simple background that toggles from one color to another. The rectangle and globe are just distractions. Comment them out, or delete them. They don't help you solve the problem. Then work through your design goals. First, you need the view to load itself and initialize all its properties. Paste this code into a new project and give it a test drive. Next, Eat Another PieceIf this works, and you understand the sequence of events, you're ready for the next bite of elephant. Keep Coding!Please return and let us know how you solved this!
|
|
I don't really know enough about it to give you the reason why it isn't animating the way you have it. But I did find a way to make it work by slightly modifying your code, and it seems to have something to do with using the Basically, I just removed the Then, I added the gradient as a background by wrapping your entire Then, move all of the modifiers that were attached to the Then the background animates. (I also changed your NavigationLinks to point to
|
|
@Obelix Thank you, thank you, thank you for this. As someone who is self taught and doesn't have any mentors, you have been tremendous in the few questions you helped me on with taking the time, going over the approach in detail and just helping me out. Learned so much from your answers. I owe you a beer (if you don't drink a coke) if we ever cross paths. Thank you again for this @Fly0strich Thank you for this approach. This helped me figure out what I was doing wrong without rearranging the code too much. I appreciate it !! |
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
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.