5

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)
}
Narayan Acharya
  • 1,459
  • 1
  • 18
  • 33
  • Try selecting your view/tableView in the interface builder. Then on the attributes inspector make sure that "Drawing" Opaque is NOT selected, and that "Clears Graphics Context IS selected. – Pochi Apr 27 '17 at 08:16
  • Just tried this @Chiquis. It did not fix the issue. – Narayan Acharya Apr 27 '17 at 08:43
  • Is your viewcontroller's "base" view transparent as well? Try setting this view to a different color. If you are using an UITableViewController try setting the tableview base color to something. It seems as the assistive touch thing is messing with the rendering somehow, but I've only seen something familiar when my actual application window was transparent and I could see the dashboard between transitions. – Pochi Apr 28 '17 at 00:54
  • Can you show how are you setting your background in your viewcontroller? – Uday Naidu Apr 29 '17 at 05:28
  • Will add code snippets as soon as possible @UdayNaidu – Narayan Acharya Apr 29 '17 at 06:22
  • @UdayNaidu added code snippet. – Narayan Acharya May 01 '17 at 05:42
  • Please check for extension, it may affect your task. so i would like to suggest you to create separate demo and test it. – kalpesh jetani May 01 '17 at 09:19
  • Another way : try to create and add separate view instead of modifying current background view of cell. – kalpesh jetani May 01 '17 at 09:25

1 Answers1

1

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
Uday Naidu
  • 532
  • 1
  • 6
  • 16