Search code examples
xcodestoryboarduistoryboard

I can't move elments in storyboard - xcode


I need to move items like labels and buttons to another position, I move them manually in the UI, but when I run the app, the moves are not done. Should I deactivate something? Or how could I do that?

I leave an image like the one I have in the storyboard, but in the app they relocate to the dotted lines.

enter image description here


Solution

  • I move them manually in the UI

    Yup, that's the problem! Don't do that.

    As the orange lines are telling you, you've already got autolayout constraints on those views. And that is what matters! The orange means that where you see the views (after moving them manually) makes no difference; where you've moved them to is not where they will be. They will be where the dotted lines are, as you rightly say — because that's where the constraints will put them.

    The way to change the size and position of views that have constraints is to change the constraints. Select the constraint you want to change and change it (in the Size inspector). Keep doing that until you're satisfied.

    (Alternatively, you can ask Xcode to change the constraints after you've moved a view manually, but I find that unreliable; it can have effects you aren't expecting.)