我想在列表视图后面部分显示背景图像。我在我的笔尖中创建了一个列表视图,后面有一个图像视图,并使列表视图背景为20%不透明度。这允许背景图像显示,但是我的单元格中的文本显示背后的白色背景,如果我在cellForRowAtIndexPath中创建单元格,则单元格也具有白色背景。
我正在cellForRowAtIndexPath事件中创建并设置单元格textLabel和detailTextLabel。
不确定如何摆脱它,或者是否有更好的方法来制作背景图像。
答案 0 :(得分:0)
我有类似的问题并通过在cellForRowAtIndexPath中将cell.contentView.backgroundColor设置为[UIColor clearColor]来解决它。
如果你不想让整个单元格透明而只是标签,你可以设置textLabel和detailTextLabel的backgroundColor属性来清除:
cell.textLabel.backgroundColor = [UIColor clearColor];
要在运行时而不是在笔尖中设置表格的背景图像,您可以从图像创建新的UIColor。像这样:
UIImage *img = [UIImage imageWithContentsOfFile: someFilePath]; // get your background image
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage: img];
[myTable setBackgroundColor: backgroundColor];
[backgroundColor release];