7

Is there any way to add subview in the "bottom" of its view,like z=0 when you use layers? I need this because when I spawn objects they need to be under another pictures,not above.

Nicola Miotto
  • 3,647
  • 2
  • 29
  • 43
Mathemage
  • 315
  • 4
  • 13

3 Answers3

19

The subviews of a UIView are sorted in a way that the last one of the array is the frontmost one, and then the first one (index 0) is the one in the back. So, to insert it in the "bottom", it's sufficent to do like this:

[view insertSubview:aView atIndex:0]
Nicola Miotto
  • 3,647
  • 2
  • 29
  • 43
4

Sure thing--just add the new view and use the sendSubviewToBack: method of the container view.

sgress454
  • 24,870
  • 4
  • 74
  • 92
2
sendSubviewToBack:

Moves the specified subview so that it appears behind its siblings.
- (void)sendSubviewToBack:(UIView *)view

source: http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html

mvds
  • 45,755
  • 8
  • 102
  • 111