UITableViewCell颜色问题与自定义表视图背景 [英] UITableViewCell color issues with custom table view background

查看:182
本文介绍了UITableViewCell颜色问题与自定义表视图背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView的自定义背景图像设置像这样:

I have a UITableView with a custom background image set like this:

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mybg.png"]];

背景看起来不错,但是我的UITableViewCells(默认单元格,不是自定义)他们,包含新项目文本的UILabel似乎也有一些背后的背景。如何删除?我已经尝试过:

The background appears fine, but my UITableViewCells (default cells, not custom) have some sort of weird tint to them, and the UILabel containing the "New Project" text also seems to have some sort of background behind it. How can I remove this? I've already tried:

cell.backgroundColor = [UIColor clearColor];
cell.textLabel.backgroundColor = [UIColor clearColor];

感谢

推荐答案

我相信这是一个讨厌的副作用,简单地将图像直接添加到您的表视图的backgroundColor。

I believe that this is a nasty side-effect of simply adding an image straight into your table view's backgroundColor.

尝试将图片添加到视图的背景颜色:

Try adding the image to the view's background color:

[[self view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"mybg.png"]]];

,然后将表格视图的backgroundColor设置为清除: / p>

and then set the table view's backgroundColor to be clear:

[[self tableView] setBackgroundColor:[UIColor clearColor]];

我希望这有助于!

这篇关于UITableViewCell颜色问题与自定义表视图背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆