Это потому, что размер ячейки изменился, но maskLayer
все еще сохраняет старый размер.На мой взгляд, чтобы исправить это, каждый раз, когда размер ячейки изменяется, удаляют и снова добавляют maskLayer
.
RateChartTableViewCell
@interface RateChartTableViewCell : UITableViewCell
@property(nonatomic, strong) CAShapeLayer* maskLayer;
... other properties
@end
@implementation RateChartTableViewCell
- (void)configureBorders {
UIBezierPath* maskPath =
[UIBezierPath bezierPathWithRoundedRect:self.bounds
byRoundingCorners:(UIRectCornerBottomLeft |
UIRectCornerBottomRight)
cornerRadii:CGSizeMake(10.0, 10.0)];
_maskLayer = [[CAShapeLayer alloc] init];
_maskLayer.frame = self.bounds;
_maskLayer.path = maskPath.CGPath;
self.layer.mask = _maskLayer;
self.clipsToBounds = YES;
self.backgroundColor = UIColor.redColor;
}
- (void)layoutSubviews {
[super layoutSubviews];
[_maskLayer removeFromSuperlayer];
[self configureBorders];
}
- (void)prepareForReuse {
[super prepareForReuse];
[_maskLayer removeFromSuperlayer];
}
@end
ViewController
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
RateChartTableViewCell* cell = // Initialize cell
// Do other things
if (indexPath.section == 0 && indexPath.row == 4) {
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; // You can move this line to |viewDidLoad|
[cell configureBorders];
}
return cell;
}