iOS Assistive Touch使用黑色补丁弄乱屏幕

时间:2017-04-06 07:02:45

标签: ios iphone swift uitableview swift3

我有一个UITableView,每个UITableViewCell都有一张黑色卡片,如背景UIView。黑卡并非完全不透明,而是具有0.6的alpha值。当我向上和向下移动滚动时,一切看起来都很好,没问题。

当我在UITableView上移动辅助触摸时,会出现什么混乱。辅助触摸只会在移动的任何地方留下黑色斑块,黑色斑点会一直停留,直到我再次滚动我的UITableView。

之前有其他人遇到过这样的问题吗?是否有任何工作/黑客可以避免这种情况?

额外:当我尝试截屏时,它会清除。

当我移动辅助触摸时会发生这种情况。

This is what happens when I move the Assistive Touch around.

这就是它的外观。

This is how it is supposed to look.

关于我如何设置表格中单元格的背景颜色和alpha的代码段。

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
    self.selectionStyle = .none
    self.backgroundColor = UIColor.clear

    self.background.backgroundColor = UIColor.black
    self.background.alpha = 0.6

    background.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [0.0, 0.0, 0.0, 0.6])
    background.layer.masksToBounds = true
    background.layer.shadowOffset = CGSize(width: -1, height: 1)
    background.layer.shadowOpacity = 0.2
    self.contentView.sendSubview(toBack: background)
}

1 个答案:

答案 0 :(得分:1)

从代码中删除此行并检查它是否有效。

background.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [0.0, 0.0, 0.0, 0.6])

可能发生的事情是你的背景层的辅助触摸的alpha和alpha是重叠的,os正试图重新计算你的视图的颜色,并且它会弄乱视图的颜色。 因此,请尝试使用以下代码为视图而不是视图层提供颜色和alpha。

 self.background.backgroundColor = UIColor.black
 self.background.alpha = 0.6