问题
I understand that UIStackViews are not rendered the same way the rest of view components are and thus they cannot be masked. Nonetheless I am sure there are work arounds.
Is there any way to mask a UIStackView? Specifically a stack view that has other UIStackViews as subviews.
回答1:
You can't, I believe. Although it's a subclass of UIView
, you still can't even set a backgroundColor
to it. Apple says:
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:).
https://developer.apple.com/documentation/uikit/uistackview
来源:https://stackoverflow.com/questions/62907180/how-to-mask-a-uistackview-in-swift