DEV Community

Cover image for #100DaysOfSwift: Project 15
KeeyboardKeda
KeeyboardKeda

Posted on

#100DaysOfSwift: Project 15

Hello !!

This project taught me about animation. It was quite simple. We used a penguin to showcase different animations on the screen by using switch/case statements.

Key Takeaways:

  1. animate(withDuration:) takes two closures. One with the switch/case statements and the second one is a completion closure.

  2. Animation closures do not need [weak self] because there is no risk of strong reference cycles.

3. CGAffineTransform is added to a views transform property. Example, self.imageView.transform = CGAffineTransform(scaleX: 2, y: 2). This make the image 2x bigger than its normal size.

  1. self.imageView.transform = .identity is used to clear the view of any animations added to the transform property.

5.Two animations can happen at the same time. Example, the following code fades the penguin out and adds a background color of green.

self.imageView.alpha = 0.1
self.imageView.backgroundColor = UIColor.green

Top comments (0)