I have a custom UITableViewCell
that contains a UILabel
that I want to have rounded corners. Like I've done many times before I set the corner radius and use maskToBounds
to do this programmatically. The cell itself is created in Storyboard. I call this code from the awakeFromNib
method of the UITableViewCell
.
- (void)awakeFromNib {
// Initialization code
_distanceLabel.layer.cornerRadius = 2.0;
_distanceLabel.layer.masksToBounds = YES; }
This works, but I can see a noticeable performance issue now when the tableViewController is pushed onto the navigation stack. The animation of the tableViewController now stutters when it is sliding in from the right when run on my device (iPhone 6). When I comment out the line _distanceLabel.layer.masksToBounds = YES;
the push animation works fine and slides in smoothly like normal.
I have been making apps for years and this is the fist time I have seen this issue. Anyone know what is happening here and how to fix this?
First try to set this,
self.layer.masksToBounds = YES;
or if this solution does not work then try following link in which fknrdcls gave very good answer in proper way regarding to protect corner radius negative impact on uitableview.
basically uitableview is subclass of uiscrollview so, below solution might be solve your problem.
CornerRadius sometimes affect the perfomance of uitableview.