简体   繁体   English

原生 iPhone 上的 Swift UITableView 黑色背景

[英]Swift UITableView black background on native iPhone

Using: Xcode 7 Beta, Swift 2.0使用:Xcode 7 Beta,Swift 2.0

I have a UITableView , in the Desktop simulator is all fine, but on my native iPhone 6+ the background on the empty rows is black我有一个UITableView ,在桌面模拟器中一切正常,但在我的原生 iPhone 6+ 上,空行的背景是黑色的

在此处输入图片说明

Setting a own background color to the TableView doesnt solve this problem.为 TableView 设置自己的背景色并不能解决这个问题。 Does anyone has a idea?有没有人有想法?

Faced the same issue in XCode 11.2.1 .XCode 11.2.1 中遇到同样的问题。 Tried to solve this in storyboard a lot.试图在故事板中解决这个问题很多。 I have set the background color of the tableview and cells to white color.我已将 tableview 和单元格的背景颜色设置为白色。 But evenif it is set in the storyboard, it still shows the default black color.但是即使在storyboard中设置,它仍然显示默认的黑色。 After this I tried setting it programmatically and it worked!!在此之后,我尝试以编程方式设置它并且它起作用了!!

tableView.backgroundColor = UIColor.white

Ok fixed.. the background color was the problem.. i choose "White color" but it seems that he understand this as "Default" and this was a transparent color.好的固定.. 背景颜色是问题.. 我选择“白色”,但似乎他将其理解为“默认”,这是一种透明颜色。 I choose a light different white background color and now it works.. very strange我选择了一种不同的浅白色背景色,现在它可以工作了..很奇怪

Thanks!谢谢!

Recently encountered the same issue whilst trying to 'dim' a cell.最近在尝试“变暗”单元格时遇到了同样的问题。 Seems the cell by default is set to be non opaque hence no transparency.似乎默认情况下单元格设置为非不透明,因此没有透明度。 Setting the value to false did the trick.将值设置为 false 就成功了。

cell.backgroundColor = .clear
cell.isOpaque = false

Then all you need to do is set the tableviews background colour.然后你需要做的就是设置 tableviews 的背景颜色。

tableView.backgroundColor = .red

为我解决问题的是手动将表格视图的背景颜色设置为白色,不透明度为 100%。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM