Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.