Objective C:如何让UITableView的背景色保持一致
我一直在尝试设置表格视图的背景颜色,但面临一个问题,
这就是我正在尝试做的事情。
//Set background color of table view (translucent)
self.tableView.backgroundColor = [UIColor colorWithRed:0.0 green:0.2 blue:0.5 alpha:0.7];
//Set frame for tableview
[self.tableView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.picker.frame.size.height)];
设置表格单元格后,我发现表格视图单元格周围的 alpha 级别不一致(参见下面的屏幕截图)
是否有办法使背景的颜色/alpha 级别保持一致? (注意:我没有设置背景图像,只设置颜色和 Alpha 级别)
谢谢!
振和
I have been trying to set the background color of my table view but am facing an issue
This is what I am trying to do.
//Set background color of table view (translucent)
self.tableView.backgroundColor = [UIColor colorWithRed:0.0 green:0.2 blue:0.5 alpha:0.7];
//Set frame for tableview
[self.tableView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.picker.frame.size.height)];
After setting the table cells, I saw that there is an inconsistency in the alpha level around the table view cell (see screenshot below)
Is there anyway to make the color / alpha level consistent for the background?
(Note: I am not setting a background image, only color and alpha level)
Thanks!
Zhen Hoe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使 UITableView 的背景清晰,并将 Opaque 设置为
FALSE
You need to make the background of the UITableView clear as well as set Opaque to
FALSE
您需要做的只是两件事:
例如,视图中有一个表视图。
在
XIB
文件中将UITableView
的背景设置为透明颜色。将表视图的容器视图的背景设置为您想要的图像。
如果 ViewController 实际上是 TableViewController ,则设置:
您可以在表视图委托(视图或表视图控制器)内部设置行背景
All you need to do are 2 things:
E.g. A view has a table view in it.
In the
XIB
file set the background of theUITableView
to clear color.Set the background of the container view of the table view to the image you want.
If the ViewController is actually a
TableViewController
then set:You can set the row background with inside the table view delegate (the view or tableview controller)
我最近自己遇到了这个问题,我认为我找到了解决方案
,尝试一下,可能需要针对您的具体情况进行一些按摩(看起来您在半透明蓝色后面也有一些图片)。
I recently ran into this problem myself and think I found the solution
Give that a shot, might need some massaging for your specific case (looks like you have some picture behind that translucent blue too).