Reputation: 20066
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.
How can I remove the background color and the border?
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:
But the borders are still showing!
Weird but works!
cell.backgroundView = nil;
Upvotes: 2
Views: 4227
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