kodeco.com Forums

How To Create an Elastic Animation with Swift

Learn how to make a custom text field with an elastic bouncing animation in this iOS tutorial.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1749-how-to-create-an-elastic-animation-with-swift
1 Like

There is a bug in the final result when textfields are convex but not concave into.
The reason is background color of ElasticView wasn’t cleared when it was in willSet block of backgroundColor function.
I fixed it by moving it into didSet block as below:

override var backgroundColor: UIColor? {
    willSet {
      if let newValue = newValue {
        elasticShape.fillColor = newValue.cgColor
    didSet {
      super.backgroundColor = UIColor.clear

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]