列表视图的背景图像仍然在单元格文本后面显示白色
我想在列表视图后面放置部分可见的背景图像。我在笔尖中创建了一个列表视图,其后面有一个图像视图,并将列表视图背景设置为 20% 不透明度。这允许背景图像显示出来,但单元格中的文本在后面显示白色背景,如果我在 cellForRowAtIndexPath 中创建单元格,单元格也有白色背景。
我正在 cellForRowAtIndexPath 事件中创建和设置单元格文本标签和详细信息文本标签。
不知道如何摆脱它,或者是否有更好的方法来制作背景图像。
I wanted to put a background image partially visible behind a list view. I created a list view in my nib with an image view behind it and made the list view background 20% opacity. This allows the background image to show thru but my text in the cells show a white background behind and if I create the cells in cellForRowAtIndexPath the cells have a white background too.
I am creating and setting the cell textLabel and the detailTextLabel in the cellForRowAtIndexPath event.
Not sure how to get rid of that, or if there is a better way to do the background image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题,并通过在 cellForRowAtIndexPath 中将 cell.contentView.backgroundColor 设置为 [UIColor clearColor] 来解决它。
如果您不想使整个单元格透明而仅使标签透明,则可以将 textLabel 和DetailTextLabel 的backgroundColor 属性也设置为清除:
要在运行时而不是在笔尖中设置表格的背景图像,您可以从图像创建新的 UIColor。就像这样:
I had a similar issue and resolved it by setting the cell.contentView.backgroundColor to [UIColor clearColor] in cellForRowAtIndexPath.
If you did not want to make the whole cell transparent but the labels only, you can set the backgroundColor attribute of the textLabel and detailTextLabel to clear as well:
To set the background image of a table at run time rather than in a nib you can create a new UIColor from an image. Like so: