Ios 无法设置tableview背景&;标签背景颜色是否相同?
我在表视图上方有一个Ios 无法设置tableview背景&;标签背景颜色是否相同?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我在表视图上方有一个UILabel。我想将标签的背景色设置为与UITableView相同 我已将ui标签背景色设置如下 self.label.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2]; cell.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2]; 我已将表格视图的背景色设置如下 self.label.backgroundColor = [UIColo
UILabel
。我想将标签的背景色设置为与UITableView
相同
我已将ui标签
背景色设置如下
self.label.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2];
cell.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2];
我已将表格视图的背景色设置如下
self.label.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2];
cell.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2];
但是我得到了两种不同的颜色?请告诉我为什么?可能您的contentView的tableviewCell背景颜色没有设置为clearColor:
cell.contentView.backgroundColor = [UIColor clearColor];
这是因为阿尔法。在
UILabel
和UITableView
后面,可能有不同颜色的不同视图,设置颜色时会产生效果。仍然没有什么区别。表视图颜色有点模糊,但标签背景完全清晰。我不明白,当使用UIColor时,它的alpha值低于1.0,您可以看穿它。因此,如果它们下面的内容不同,您所看到的就不同了。请尝试cell.backgroundColor=[UIColor clearColor],而不是cell.contentview.backgroundColor;