I have a cornerRadius
set on a UIView
and a UIImageView
inside the same UIView
. I am calculating the corner radius with RockProfileView.frame.size.height / 2
but the UIView stopped showing in iOS 10.
After further checking i found the value of RockProfileView.frame.size.height / 2
is coming out to be 1000.0 while the width and height constraint is set to 64.0
When I hardcoded the RockProfileView.layer.cornerRadius = 32
to 64/2 it works just fine.
What could be the issue ?
Full code:
RockProfileView.layer.cornerRadius = RockProfileView.frame.size.height / 2
RockProfileView.clipsToBounds = true
RockProgressView.layer.masksToBounds = true
As answered by Rob, I've moved the code from viewDidLoad
to viewDidAppear
and the problem is fixed.
OR
Adding self.view.layoutIfNeeded()
before your code in viewDidLoad
also solves the issue.
In case of UITableViewCell, Inside awakeFromNib
add [self layoutIfNeeded];
before updating the corner radius should solve all the issues.