Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Assistive Touch messing up screen with black patches

I have a UITableView with each UITableViewCell having a black card like background UIView in it. The black cards are not entirely opaque but instead have an alpha of 0.6. All looks fine when I move scroll up and down, no issues.

What messes it up is when I move the Assistive Touch around on the UITableView. The Assistive Touch simply leaves black patches around wherever it was moved and the black patches stay until I scroll my UITableView again.

Has anyone else encountered such an issue before? Is there any work around/hack to avoid this?

Extra: When I try to take a screenshot it clears up.

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

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

This is how it is supposed to look.

This is how it is supposed to look.

Code snippet as to how I am setting the background color and alpha for the cells in the table.

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)
}
like image 939
Narayan Acharya Avatar asked Nov 07 '22 23:11

Narayan Acharya


1 Answers

Remove this line from your code and check if it's working.

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

Maybe what's happening is your background layer's alpha and alpha of assistive touch are overlapping and os is trying to recalculate color of your view and it's messing the color of the view. So try giving your color and alpha to the view instead of a layer of the view using the following code.

 self.background.backgroundColor = UIColor.black
 self.background.alpha = 0.6
like image 107
Uday Naidu Avatar answered Nov 14 '22 23:11

Uday Naidu