In my app I am using UIView
subclasses to display all kinds of information. I want this views to appear round, so I set the cornerRadius
on the views layer
to self.bounds.size.width / 2
.
This works as expected, until I try to animate them. I animate my view using the UIView.animateWithDuration
, for example:
UIView.animateWithDuration(0.2, animations: { () -> Void in
self.myView.frame = CGRectInset(self.myView.frame, -20, -20);
}) { (done) -> Void in
}
I would like my view to also update the cornerRadius of the layer in the same animation (or a seperate animation, because the cornerRadius changes aren't animated with the animateWithDuration
.
Here is what I already tried:
- Subclass a CALayer, which draws a circle and just put that on top of MyView.layer.
- Perform a CABasicAnimation while the
UIView.animatewithDuration
is running
But all of them result in screwed results, because either the bounds aren't updated yet, or the resize of the added CALayer is done before the other animation is finished. I want it to be a smooth transition.