I have a UILabel
that I am animating the constraints for so that it drop down into view. I am using layer.cornerRadius
to give the view rounded corners, but for whatever reason after the animation completes the corner radius is removed.
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.7 initialSpringVelocity:0.4 options:UIViewAnimationOptionCurveEaseInOut animations:^{
if (shouldShow) {
self.labelOverMapTopConstraint.constant = 16;
} else {
self.labelOverMapTopConstraint.constant = -40;
}
[self.view layoutIfNeeded];
} completion:nil];
cornerRadius is set in viewDidLoad
.
Is there a way to prevent this from happening?
2
Answers
You also need to set the corner radius on
viewDidLayoutSubviews
I suspect you’re subclassing UILabel here since it looks like you have padding in there, is that correct?
There could be something going awry with any custom drawing/calculations you’re doing in there, so it would probably be helpful to post that code for inspection as well.
A few questions:
I wasn’t able to reproduce the issue in a test project with a vanilla UILabel. I then tried it with a UILabel subclass which includes additional padding and still wasn’t able to reproduce it there.
I’ve included example code snippets below:
And here’s what it looks like: