Created
December 4, 2012 16:51
-
-
Save d-amend/4206103 to your computer and use it in GitHub Desktop.
Selecting UITableViewCells in grouped UITableViews with custom color or view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <QuartzCore/QuartzCore.h> | |
@implementation CustomTableViewController | |
-(void)setSelectionViewForCell:(UITableViewCell*)cell withRoundedRectCorners:(UIRectCorner)rectCorners | |
{ | |
CGRect cellRect = CGRectMake(0, 0, cell.bounds.size.width-18, cell.bounds.size.height); | |
UIView *view = [[UIView alloc] initWithFrame:cellRect]; | |
if (rectCorners != 0) { //we need rounded corners, beginning or end of a tableViewSection | |
UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:cellRect byRoundingCorners:rectCorners cornerRadii:CGSizeMake(10.f, 10.f)]; | |
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = cellRect; | |
maskLayer.path = maskPath.CGPath; | |
view.layer.mask = maskLayer; | |
} | |
[view setBackgroundColor:[UIColor redColor]]; | |
[cell setSelectedBackgroundView:view]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment