I am trying to animate UIView using UIView.transition with [.transitionCurlUp] as argument option. However, the corners are still shown as invisible elements that the shadow falls on:

class ViewController: UIViewController {
@IBOutlet weak var buttonToBeCurled: UIView! {
didSet {
let tap = UITapGestureRecognizer(target: self, action: #selector(curlTappedView))
buttonToBeCurled.addGestureRecognizer(tap)
buttonToBeCurled.layer.cornerRadius = 35
buttonToBeCurled.backgroundColor = UIColor.purple
}
}
@objc func curlTappedView(_ gesture: UITapGestureRecognizer) {
let tappedView = gesture.view!
UIView.transition(with: tappedView, duration: 3.0, options: [.transitionCurlUp], animations: {
})
}
}
Is there something about the way animation works while curling the uiview?


The shadow and its animation is generated internally by the transition, based on the view frame.
We can confirm that by using a plain, clear
UIView:This might work for you...
We'll embed the
buttonToBeCurledview in a "container"UIView, set.clipsToBounds = trueon the container, and give the container the same rounded corners:Here's how that looks, midway through the animation:
The visual effect looks okay, but... because the shadow animation outside the view bounds (which we now don't see) takes up time, there is a delay before the rest of the animation begins.
Using a shorter duration, and using
.curveLinearinstead of the defaultcurveEaseInOutproduces a somewhat better result.