Search code examples
ioscore-animation

Limit animation space inside view


I have tableView cell. When I add cell to table view, simple animation of scaling of cell element is fired

 UIView.animate(withDuration: 1, animations: {
            self.quantityBackround.transform = CGAffineTransform(scaleX: 0.05, y: 0.05)
        }) { (success) in
            UIView.animate(withDuration: 0.1) {
                self.quantityBackround.transform = CGAffineTransform.identity
            }
        }

Looks like this

enter image description here

The problem is that when circle expands it doesn't respect bottom border of cell and expands above it. What I want is to limit animation so it will be visible only inside cell space. (Like top part of circle - it is limited by top border of cell and is not seen)

How can I do this ?


Solution

  • You should set the clipsToBounds property for the view's superview.

    view.clipsToBounds = true