Tuesday, 24 March 2015

uitableview border layer

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    
    if (expansesArray.count != 0) {
    NSUInteger rowsCount = [self tableView:tableView numberOfRowsInSection:indexPath.section];
    NSUInteger heightvalue = (rowsCount * 63)+ 40; // 40 header height, 63 cell height
        CAGradientLayer *gradient = [CAGradientLayer layer];
        gradient.frame = CGRectMake(0, 0, 300, heightvalue);
        gradient.borderWidth = 1.0f;
        gradient.cornerRadius = 5.0f;
        gradient.borderColor = [[UIColor orangeColor]CGColor];
        [expensesTable.layer addSublayer:gradient];
    }

}

No comments:

Post a Comment