ios - Resize button in swift/xcode with Autolayout enabled -


i have read in several other posts topic, , it's understanding resize object when autolayout enabled, can change constant properties of constraints in code.

i have 2 buttons side side, this

[delete][ post ]

and take entire width of screen. want hide delete button views, , when happens, stretch post button take entire width of screen. in code, have:

self.postbuttonleadingconstraint.constant = self.deletebuttonleadingconstraint.constant self.deletebutton.hidden 

my delete button hides fine, post button stays at. doing wrong? input appreciated.

edit: if matters, buttons constrained follows:

delete button leading constrained leading edge of view

post button leading constrained trailing edge of delete button

delete , post button set equal each others' widths

both buttons have tops , buttons constrained view in, don't see how relevant.

if you're targeting ios 9 , higher i'd suggest using uistackview. super easy way, matter of adding and/or removing button from/to stack view. here's little sample understand.


Comments