UITableView background with alpha color causing a problem with UITableViewCell

I'm trying to get a translucent uitableview, with this color

[UIColor colorWithRed:(247.0/255.) green:(151.0/255.0) blue:(121.0/255.0) alpha:0.38]; 

This is normal if there are only empty cells, but when there is content inside the cell, the background becomes more dense. It is as if the cell itself had the same table background, so that the transparency multiplied.

Cells with content inside are translucent, but with irregular alpha.

The table background is set correctly.

 self.myTable.backgroundColor = bgcolor; 

The cell background must be transparent and opaque

 self.contentView.backgroundColor = [UIColor clearColor]; self.contentView.opaque = NO; 

So why does he have this kind of behavior? Can anybody help me?

+1
source share
3 answers

I decided to use a transparent UITableView and placed a translucent UIView.

+2
source

This is probably caused by cell caching. Have you tried disabling the cache? This is very inefficient, but it can help you find a solution to this problem if it is really a problem with the UITableViewCell cache.

You can disable it without using the "dequeueReusableCell" function in your tableView: cellForRowAtIndexPath: function.

0
source

I just met the same problem.

After hacking - (void) setBackgroundColor in class UITableViewCell it seems that it is called by internal methods of UITableView right after

 -(UITableViewCell*)tableView:cellForRowAtIndexPath: 

your delegate method.
Another workaround is overloading

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

in your delegate and set the background color of your cells here.

0
source

All Articles