skip to Main Content

I am at the start of developing iOS applications with xCode 7.2.1 (for iOS 9.2 / Autolayout / Size classes)
I am trying to place a button over an image. When the image is loaded the button is under the image.
Is there a way, like in CSS to set z-index for all elements or a level-viewer like in Photoshop?

2

Answers


  1. You can change its z-index by clicking on your object -> layout menu -> bring to front

    i also do think you can change its position by dragging it over other object in the item list on the left in your story

    Login or Signup to reply.
  2. You can use the following methods to organise the UIView programmatically:

    bringSubviewToFront:
    sendSubviewToBack:
    insertSubview:aboveSubview:
    insertSubview:belowSubview:
    insertSubview:atIndex:
    exchangeSubviewAtIndex:withSubviewAtIndex:
    

    Here you can read up on the above.

    However if you’re creating the views with storyboards or in an xib then reordering the items will give you the desired effect.

    example ordering

    Here the username UIView is behind the email UIView.

    Another way of ordering is mentioned by PudiPudi, you can click the item and change it through the menus.

    Another solution is the ordering at which you’re adding the views programmatically. Simply changing the order of the, for example, addSubView() function will give a different layering.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search