3

Every view has a layer that does the rendering. What confuses me is that you can't set the corner radius or border to the stack view, yet when you hide one of the arranged subviews the rest of them fill up the stack view.

Furthermore, Apple doc says that the stack view only manages its arranged subviews.

But, how does the stack view resize its subviews? Does the stack view's layer do the resizing when an arranged subview is hidden? If not, what is then the usage of the layer property in a stack view?

Rango
  • 229
  • 1
  • 4
  • 14

1 Answers1

2

The UIStackView is a nonrendering subclass of UIView; that is, it does not provide any user interface of its own. Instead, it just manages the position and size of its arranged views. As a result, some properties (like backgroundColor) have no effect on the stack view. Similarly, you cannot override layerClass, draw(:), or draw(:in:).

consider placing the stack view inside another UIView and giving that view a corner radius or border.
Apple Doc

potato
  • 333
  • 1
  • 10