2014-05-03 299 views
2

我将背景颜色设置为表格视图。颜色具有30%的透明度。问题是没有单元格的那部分表格,透明度设置显示颜色。但单元格显示不透明。TableViewCell颜色问题

我没有在代码中设置颜色。表格背景颜色在故事板中设置。请要求提供任何其他信息。

enter image description here

表在故事板:

enter image description here

代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    MyCell *cell = (MyCell *) [self.tableView dequeueReusableCellWithIdentifier:CELL_IDENTIFIER forIndexPath:indexPath]; 

    // Set cell content 
    cell.NameLabel.text = ...; 
    cell.SequenceLabel.text = ...; 
    cell.NumberLabel.text = ...; 

    cell.backgroundColor = tableView.backgroundColor; // Also tried setting to [UIColor clearColor] 

    return cell; 
} 
+0

那么问题是什么?你希望细胞显示透明度? – Avt

+0

@Avt是的,单元格应该具有相同的颜色和相同的alpha值。 – Geek

+0

@FahimParkar代码中没有任何显示。代码只是设置标签值。没有重用标识符,它将如何工作?它的自定义单元。 – Geek

回答

1

您在表视图设置透明度,但细胞的观点并不透明。只需将每个单元的背景颜色设置为透明。

cell.backgroundColor = [UIColor clearColor]; 

或将其设置为相同的颜色表视图是

cell.backgroundColor = self.tableView.backgroundColor; 
+0

试了两个。他们都没有工作。 – Geek

1

你必须设置单元格背景clearcolor以及或者如果要设置每个单元格的背景图像比你必须使用透明的图像,也设置该图像的阿尔法0.3所以它将是透明的。

cell.backGroundColor=[UiColor ClearColor]; 

,或者你必须设置你的背景的Alpha颜色

cell.imageView.alpha=0.3; 
+0

我不使用背景图像单元格。 – Geek

+0

比我认为cell.backgroundcolor = [uicolor clearcolor]必须工作在我的应用程序至少工作 –

+0

这没有奏效。我已经按照'reecon'的建议尝试过了。请参阅更新的问题。我添加了一张图片 – Geek

2

嗨尝试使用下面的代码&把自己的RDB值:

cell.backgroundView.backgroundColor = [UIColor colorWithRed:1.0f green:2.0f blue:85.0f alpha:0.3f]; 
3

设置的背景颜色该单元格与具有相同透明度的tableview背景颜色相同,并将tableview背景色设置为透明颜色。 我希望这会有帮助。