WallyAmerica WallyAmerica - 2 years ago 140
Swift Question

How can I set the cornerRadius of a UIStackView?

I'm updating my app to use UIStackViews, now that most people should have updated to iOS 9.

In the old version, I made a UIView consisting of two UITextFields and set its layer.cornerRadius property.

In the new version, I created a UIStackView consisting of the same two UITextFields, instead of the UIView. When I try setting its layer.cornerRadius property nothing seems to happen. The documentation doesn't seem to have any helpful/relevant information.

Answer Source

UIStackView just manages the position and size of its arranged views, the cornerRadius has no effect. Try to add a custom view below the stackView and set the cornerRadius of it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download