Goal C: How to make the background color UITableView Consistent

I am trying to set the background color in my table view, but ran into a problem

This is what I am trying to do.

//Set background color of table view (translucent) self.tableView.backgroundColor = [UIColor colorWithRed:0.0 green:0.2 blue:0.5 alpha:0.7]; //Set frame for tableview [self.tableView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.picker.frame.size.height)]; 

After installing the table cells, I saw that there is an inconsistency in the alpha level around the table view cell (see screenshot below)

tableView BackgroundColor

Anyway, so that the color / alpha level matches the background? (Note: I do not set the background image, only color and alpha level)

Thanks!

Zhen hou

+6
source share
3 answers

I recently ran into this problem and thought I found a solution

 self.tableView.backgroundColor = [UIColor clearColor]; self.parentViewController.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.2 blue:0.5 alpha:0.7]; 

Give this shot, you may need to massage for your specific case (it looks like you have an image behind this translucent blue too).

+22
source

You need to make the background of the UITableView clear and set Opaque to FALSE

 [self.tableView setBackgroundColor: [UIColor clearColor]]; [self.tableView setOpaque: NO]; 
+5
source

All you have to do is 2 things:

eg. The view has a tabular view. In the XIB file XIB set the background to a UITableView to clear the color. Set the background of the container view in the form of a table to the desired image.

 self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"app_background.png"]]; 

If the ViewController is actually a TableViewController , then set:

 self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"app_background.png"]]; 

You can set the row background inside the table view delegate (view controller or table)

 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if ([indexPath row] % 2 == 0) {//248 G:192 B:100 [cell setBackgroundColor: [UIColor redColor]]; } else { [cell setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:@"xyz.png"]]]; } } 
0
source

Source: https://habr.com/ru/post/888495/


All Articles