0

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.

jcpennypincher
  • 3,970
  • 5
  • 31
  • 44

1 Answers1

0

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.

Rich
  • 8,108
  • 5
  • 46
  • 59