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