swift - 使用图像作为 UITableView 背景;背景仍然显示黑色

标签 swift uitableview

我有一个灰色的自定义图像,用作 UITableView 的背景。图像为 PNG,具有适当的 alpha 设置,具有圆角,并且加载良好。然而,尽管使用了以下内容,我仍然看到黑色“背景”,其中角落变得透明。

enter image description here

tableView.backgroundView = UIImageView(image: UIImage(named: "someImage"))
tableView.backgroundColor = UIColor.clear

我还将 TableView 背景设置为明亮的颜色,看看这是否是问题所在,但背景仍然是黑色。

enter image description here

如何使该区域完全透明,使其看起来好像我的圆角是 TableView 的末端?

谢谢!

最佳答案

尝试一下片段。希望这有效

let backgroundImage = UIImageView(frame: UIScreen.main.bounds)  
backgroundImage.image = UIImage(named: "bg")
backgroundImage.contentMode = UIViewContentMode.scaleAspectFill

关于swift - 使用图像作为 UITableView 背景;背景仍然显示黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54546292/

相关文章:

ios - 从图库中获取图像很慢

ios - cellForRowAt 在 childTableView 中不起作用

iOS UISearchController TableView

arrays - UITableView 中的 UICollectionView - 我想在 CollectionVewCell 中显示数据

swift - 单击单元格按钮时应用程序崩溃

ios - 如何检查通知的应用程序设置?

ios - 如何在 Google maps ios sdk 中过滤自动完成国家?

ios - 类型...的值没有成员

swift - 从 Api Url 下载图像并使用 Alamofire 快速显示在收藏 View 中

ios - 如何使 PFQueryTableView 在 UIViewController 中工作