3

I just noticed something weird in the UIView's class reference. Under alpha it states:

This value affects only the current view and does not affect any of its embedded subviews.

But as you most certainly know, that is not the case. If you change the alpha of a superview all subviews also apply the new alpha.

Is it a mistake in the documentation or am I misunderstanding it?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Tobi
  • 5,499
  • 3
  • 31
  • 47
  • Maybe this is related/helpful: http://stackoverflow.com/questions/8581994/ios-controlling-uiview-alpha-behaviour-for-subviews?rq=1 – Thilo Oct 25 '12 at 11:14
  • Thx for your answer. I know how to handle this, I was just wondering why the documentation says something wrong (at least the way I understand it) – Tobi Oct 25 '12 at 11:23
  • 2
    I think it's meant this way: Setting the value will not change the alpha values of the subviews. In the end - of course - all subviews will also be affected by the parent alpha, but their own alpha is not changed. – jimpic Oct 25 '12 at 11:33
  • I thought about that too, but if you look at the link Thilo provided, you can see that each view seems to have an alpha of 0.3, thus you can see one white view through the other and the red view through both. They are clearly rendered individually, each with an alpha of 0.3 – Tobi Oct 25 '12 at 11:37
  • You may want to check the difference between alpha of the view vs. alpha component of its background color. – Cynichniy Bandera Feb 27 '18 at 21:33

1 Answers1

1

This value affects only the current view and does not affect any of its embedded subviews.

I understand this as:

Changing the alpha value on a view will not change the alpha value on any subviews. As in, whilst the subviews will appear to have changed their alpha, their .alpha property value will not change when the superview's .alpha is changed.

WDUK
  • 18,870
  • 3
  • 64
  • 72