I am trying to automatically expand a UIButton width to the width of an interface upon orientation change.
Does anyone have working code for this? I have tried using AutoResizing mask, but perhaps I'm not using the correct one.
I am trying to automatically expand a UIButton width to the width of an interface upon orientation change.
Does anyone have working code for this? I have tried using AutoResizing mask, but perhaps I'm not using the correct one.
There's multiple ways of doing this.
In your view controller sub class overrride -willAnimateRotationToInterfaceOrientation:duration:
or -willRotateToInterfaceOrientation:duration:
You could also override -viewWillLayoutSubviews
and then adjust the frame depending on the orientation by querying self.interfaceOrientation
.
And change the size of the button in that method, either by adjusting the constraints or changing the frame of the button.