iOS Build an Interactive Story App with Swift Personalizing the Story User Input Through a Text Field

Gene Bogdanovich
Gene Bogdanovich
14,618 Points

Compression Resistance & Content Hugging

Hello. Let's say I want to make name text field and start adventure button the same width. I set the Equal Widths constraint using control drag but it just stretches out the start adventure button. I don't want that. I want the start adventure button to have a size according to its content and text field be the same size as the button. I tried tweaking Compression Resistance and Content Hugging on both elements but it didn't work. How can I work this out? Here's an image of a storyboard: https://ibb.co/h2phSVc Thank you.

1 Answer

Clark Reilly
Clark Reilly
6,204 Points

Your problem is the leading and trailing constraints on the text field. You need to get rid of those before setting it to equal widths with the button. After doing that, it works fine.

Gene Bogdanovich
Gene Bogdanovich
14,618 Points

Thank you so much for taking time.