When I call setNeedsDisplay()
on my UIView's CALayer (either directly, or via needsDisplayOnBoundsChange
), it draws the background as black.
myView.layer.setNeedsDisplay()
When I call 'setNeedsDisplay()' on the UIView directly, it doesn't show up as black:
myView.setNeedsDisplay()
Why does this happen, and how can I fix it?
The problem was that my view's background color was somehow set to
nil
instead of.white
or.clear
, for example.It seems odd that this happens only when calling it on the layer and not the view.
To reproduce...
This shows up as white:
This causes the view to display as black: