April 2020
Beginner
316 pages
8h 20m
English
Now, let's head on over to our Recipe app and make some changes ourselves. We'll start by heading on over to RecipeDetailView.swift and finding our favorite button. Add the following highlighted code to add a little spin to our selection:
Button(action: { Helper.addRemoveFavourite(recipe: self.recipe) self.recipe.favourite.toggle() withAnimation(.spring()) { self.angle = self.angle == 1080 ? 0 : 1080 }}) { Image(systemName: isFavourite ? "star.fill" : "star") .resizable() .aspectRatio(contentMode: .fit)}.rotationEffect(.degrees(angle)).frame(height: 45)
Here, we've added an explicit animation to our star view. Looking at the action in our button, it's clear we're performing a .spring() animation when we set the angle of our ...
Read now
Unlock full access