3

this should be simple but I am having trouble setting the width of textfields and/or buttons with placeholders in storyboard so that it looks right in the simulator..

I have set the width to 200. It looks find in storyboard, however, the textfield shrinks to the size of the placeholder when I build and run.

In the case of buttons, I also set the width to 200 but the button shrinks to the size of the label.

What am I not doing correctly?

1
  • Please provide image for your problem, since its auto-layout issue.
    – Bista
    May 18, 2015 at 15:55

1 Answer 1

5

Try setting width and height constraints of the textfield and button as displayed below:

enter image description here

Then click "Add 2 Constraints" (I know it says 3 in the image, ignore that).

2
  • That worked. However, is it true that you must use constraints for this and the attributes inspector is of no help? Seems like I am going to need an awful lot of constraints i.e. several for every design element. May 18, 2015 at 20:09
  • The attributes inspector should be sufficient for what you'd like to do. Check out this answer: stackoverflow.com/a/26482088/2919327
    – Leverin
    May 19, 2015 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.