I am doing an animation practice from Apple's tutorial. The task is do build a UI of a music player. Each of control buttons has a "shadow" view underneath it, which appears when button is pressed:
Here is my code in viewDidLoad():
background.layer.cornerRadius = background.bounds.width / 2
background.backgroundColor = .clear
The thing is that tutorial insists to also add a clipsToBounds property for each of shadow views:
background.layer.cornerRadius = background.bounds.width / 2
background.clipsToBounds = true
background.alpha = 0.0
When I run my code, everything works fine, and shadow views appear as circles. So why use clipsToBounds here, considering that view is clipping to bounds of itself? Am I missing something here?
And while it's in the code - is using .alpha
property a better practice than changing backgroundColor to .clear
and back for animation purposes?