0

I have two views:

View A with alpha 1.0
View B with alpha 0.5

Both are subviews, with view B added as a subview after view A which implies that the opaque view A is partially visible through the semi-transparent view B.

When I call setNeedsDisplay on both views, only view B's drawRect is invoked.

I am aware that setNeedsDisplay doesn't immediately invoke drawRect so I guess if A was completely invisible, this would make sense.

When I can see part of view A through B, why is A's drawRect still not get invoked? Maybe I didn't understand the documentation correctly?

Sid
  • 9,508
  • 5
  • 39
  • 60
  • what if you remove View B (so it's not obscuring View A) does your view redraw itself as you think it should? – Jessedc Sep 27 '12 at 01:59
  • This is just a theory, but make sure View B's `opaque` property is set to NO. This is a seperate property from `alpha` and is used by the OS to perform drawing optimisations - like, perhaps, preventing the drawing of views underneath. – Xono Sep 27 '12 at 01:59
  • @Jessedc Yes it does. When I have a single view present, it renders exactly as it should.... – Sid Sep 27 '12 at 16:04
  • @Xono Unfortunately, that did not work :( Really good suggestion though.... – Sid Sep 27 '12 at 16:05

1 Answers1

1

To answer my own question - drawRect is not invoked in this case.

Sid
  • 9,508
  • 5
  • 39
  • 60