Thursday, 22 January 2015

UITableViewCell selection with Custom height

 cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
        // change background color of selected cell
        UIGraphicsBeginImageContextWithOptions(cell.bounds.size, NO, 0);
        // change this color as you like
        [[UIColor  colorWithRed:(80.0f/255.0f) green:(170.0f/255.0f) blue:(57.0f/255.0f) alpha:1.0f] setFill];
        // fiddle with this size as you like
        [[UIBezierPath bezierPathWithRect:CGRectMake(0,0,cell.contentView.frame.size.width, 140)] fill];
        [UIBezierPath bezierPathWithRoundedRect:cell.selectedBackgroundView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(20.0f, 0.0f)];
        UIImage* im = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
       
        UIImageView* iv = [[UIImageView alloc] initWithImage:im];
        // rounded = nil;
        cell.selectedBackgroundView = iv;

No comments:

Post a Comment