IPhone Interface Builder: Z-Index, Z-order of a button, image, ui element, etc?

There is a Z ordering without using subviews. For one thing there are menu options for "send to front" and "send to back". Also however, if you look at the elements in your view as a tree of elements, you can re-order them there (rather than in the view itself) just by dragging Subviews are great for grouping but not as useful for ordering (except that the whole "set" stays at the same level).

There is a Z ordering without using subviews. For one thing there are menu options for "send to front" and "send to back". Also however, if you look at the elements in your view as a tree of elements, you can re-order them there (rather than in the view itself) just by dragging.

Subviews are great for grouping but not as useful for ordering (except that the whole "set" stays at the same level).

In XCode development, a UI element, or "view" is in front of another view when it is a subview of that view. For example, if view B is a background and view C is a control, to place the control above the background (i.e. Closer to the user), you would make view C a subview of view B.In Interface Builder, this is accomplished by dragging the control into the background.

Essentially, you are looking at a tree structure, with the views in the background being near the root of the tree, and views in the foreground (closer to the user) being near the leaves of the tree. The Windows and Views document from Apple's iPhone developer documentation may help to clear things up. Note 1: You should almost never overlap individual controls, such as buttons and text fields.

Doing so goes against Apple's user interface guidelines. You can, of course, still do this if you want to, but you need to be aware that you are stepping out of the safety zone. If you are simply writing a "normal" iPhone application, your best bet is to stick to Apple's way of doing things.

Note 2: If, for some reason, you do need things to overlap in a specific way, you can make use of CALayer objects to keep everything properly ordered. CALayer objects are part of Apple's Core Animation technology.

1 Concisely explained – TechZen Feb 16 '10 at 20:53 I see what you're saying, but what if you had multiple controls within the same view. For example, say I have a button MyButton inside a view MyView, but I wanted an Image to be over the button (and yes, I want an image over a button, I don't want to use button's inherent image property). Is there a possible way to do this or no?

– foreyez Feb 16 '10 at 22:05 Yes, it can be done, although it may be a bit more difficult than simple drag-and-drop. See stackoverflow. Com/questions/466297/… – e.

James Feb 16 '10 at 22:10 hmm, apple needs to get their act together about this one. Z-index is the way to go. This is primitive.

Thanks for your help though! – foreyez Feb 16 '10 at 22:11 If you want to do it properly, using CALayers is the way to go. In IB, if you enable layers for your base view (the one that will contain the overlapping siblings), then dragging the image on top of the button should just work.

I think you will have to add the button first, and then add the image, and then drag the image on top. Also, keep in mind that you may have to jump through some hoops to get "click-through" to work. – e.

James Feb 16 '10 at 22:13.

I achieved what I wanted by clicking on a ui element (button, image, text, etc) and going to the Layout menu (at the top of screen) and then I used "bring to front", "send to back", etc.

1 +1... it's hysterical to me that there are all these complicated explanations, yet the right answer was not submitted. (I guess Kendall did actually mention the menu items, but didn't go into where they were located. ) Purely speculation, but I imagine CALayer objects MUST have some concept of z-index.

– livingtech Sep 28 '10 at 16:03 In Xcode 4.2 you'll find the options in menu up top: Editor->Arrange – MdaG Oct 28 at 13:35.

In XCode development, a UI element, or "view" is in front of another view when it is a subview of that view. For example, if view B is a background and view C is a control, to place the control above the background (i.e. Closer to the user), you would make view C a subview of view B.

In Interface Builder, this is accomplished by dragging the control into the background. Essentially, you are looking at a tree structure, with the views in the background being near the root of the tree, and views in the foreground (closer to the user) being near the leaves of the tree. The Windows and Views document from Apple's iPhone developer documentation may help to clear things up.

Note 1: You should almost never overlap individual controls, such as buttons and text fields. Doing so goes against Apple's user interface guidelines. You can, of course, still do this if you want to, but you need to be aware that you are stepping out of the safety zone.

If you are simply writing a "normal" iPhone application, your best bet is to stick to Apple's way of doing things. Note 2: If, for some reason, you do need things to overlap in a specific way, you can make use of CALayer objects to keep everything properly ordered. CALayer objects are part of Apple's Core Animation technology.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions