I have made a game with many objects on the screen which go from right to left, I have placed these items on my storyboard.
It's a single view application and the Title logo and play button aren't displaying how I would like them to on a 3.5" screen, so i am trying to make the app keep them a certain distance away from the screen edge, i have tried using constraints for this, but i am unable to constrain it to the screen edge rather than another item on the story board.
Since these other items on the story board are moving, it provides me with yellow errors that the content its aligned to is "ambiguous".
Any help would be much appreciated, should I try two story boards instead?
If the view containing the title logo
and the play button
is not moving, then you may do this the following way:
Add a Bottom space to superView
constraint, to your play button
in storyboard.
Steps:
With the play button object as selected, Click on
Editor -> Pin - > Bottom Space to Superview
Similar methods can be used with other objects too, such as adding constraint Top Space to Superview
for Title Logo
, so that the logo remains at a fixed position at the top.
For further doubts regarding constraints
and Autolayout
, you may refer these wonderful tutorials:
Update:
If you get compiler warnings such as
"Frame for "Image View - Title.png" will be different at run time."
It is because you have changed the frame of an item after adding the constraint.
If you want the new position:
Editor -> Resolve Autolayout issues - > Update constraints
If you want the original previous position:
Editor -> Resolve Autolayout issues - > Update frames
Hope this helps! :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.