Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 910
WallyAmerica Avatar asked Nov 25 '15 23:11

WallyAmerica


2 Answers

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.

like image 96
ZHZ Avatar answered Sep 30 '22 12:09

ZHZ


add cornerRadius on stackview's superview and enable clipsToBounds property of the superview so that the subviews are confined to the bounds of the superview.

like image 40
tahmina Avatar answered Sep 30 '22 13:09

tahmina