Autolayout resize button based on text and have textfield fill available space

Try these autolayout constraints:

23226220_Autolayout_Constraints


Basically:

  1. UITextField object's width constraint should be a Less Than or Equal relation
  2. UIButton object's width constraint should be a Greater Than or Equal relation
  3. UITextField object's horizontal Content Hugging Priority should be 249 (as per my constraint settings shown above)

And related code as:

[buttonObject setTitle:@"Button title is too... zzz" forState:UIControlStateNormal];
[buttonObject sizeToFit];

...or something along these lines