Reputation: 769
Upon changing the highlight color of the cell when selected, the box drawn around the top and bottom of the table no longer clips within the table's borders.
I have tried clipsToBounds with both tableView and the cells, but with no luck.
Any solutions?
Thanks!
image of the problem >
Upvotes: 0
Views: 143
Reputation: 673
I have a idea how to make the effect you need work, may not be the best way but you can have a try.
first check if the cell is the last cell; if so:
UIBezierPath *lastCellMask;
lastCellMask = [UIBezierPath bezierPathWithRoundedRect:cell.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(3.0, 3.0)];
CAShapeLayer *cellMaskLayer = [[CAShapeLayer alloc] init];
cellMaskLayer.frame = cell.bounds;
cellMaskLayer.path = lastCellMask.CGPath;
cell.layer.mask = cellMaskLayer;
and do the reverse for the first cell
This works for me, check if this can help u
Upvotes: 1
Reputation: 10175
The problem is that you are using grouped
style for your table view. The grouped table view doesn't have the margins that you are seeing in the UI, and using clipToBounds
won't help because the cells bounds are exactly the ones you are seeing when you are selecting the cell. What you could do is use the cornerRadius
layer property for your cell (only the first and last cell in the section) in order to round the corners and create the desired result.
Upvotes: 0
Reputation: 4480
looking at the image, try
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
Upvotes: 0