azamsharp
azamsharp

Reputation: 20066

Remove the UITableView Section Border and Background Color with Static Cells ?

I am using UITableView with static cells to make a small form.

I added number of sections in the UITableView but now I have to remove the background color and the border of the section that displays the Login and Forgot Password button.

Check out the screenshot below.

enter image description here

Question 1

How can I remove the background color and the border?

Question 2

Also is there anyway to change the background color of the view. This view inherits from UITableViewController. I believe that I need to change the color of section or the group.

I assigned the identifier to the cell and got to remove the background color.

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    if([cell.reuseIdentifier isEqualToString:@"ButtonsCell"])
    {
        cell.backgroundColor = [UIColor clearColor];



        NSLog(@"login buttons cells found");
    }


}

Here is the image:

enter image description here

But the borders are still showing!


SOLUTION

Weird but works!

cell.backgroundView = nil; 

Upvotes: 2

Views: 4227

Answers (1)

DenVog
DenVog

Reputation: 4286

I think you want to do a switch cased based on your section within cellForRowAtIndexPath. Then replace the background of that row with a view that's transparent.

switch (section)
    {
        case BACKGROUND_SECTION:
        {
            // Only way I could find to get row centered
            segmentCell.selectionStyle = UITableViewCellSelectionStyleNone;
        [segmentCell setAccessoryType:UITableViewCellAccessoryNone];
            // Make the cell background transparent
            UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
            backView.backgroundColor = [UIColor clearColor];
            segmentCell.backgroundView = backView;
        }
}

Upvotes: 2

Related Questions