How can I add a subview to the second to highest position on the stack? That is, say I have 3 subviews, with number 3 being the visible on top. How can I add a new view that is directly below that one and push the rest down?
Thanks!
How can I add a subview to the second to highest position on the stack? That is, say I have 3 subviews, with number 3 being the visible on top. How can I add a new view that is directly below that one and push the rest down?
Thanks!
Lets assume you have 3 subviews on your parentView. after adding all the subviews call this method-
[parentView insertSubview:yourView atIndex:parentView.subviews.count-1]
there are also other simpler methods such as
[parentView insertSubview: aboveSubview: ]
[parentView insertSubview: belowSubview: ]
Cheers , hope this helps !
There is this API:
insertSubview:newView belowSubview:oldView
didn't see it when I first looked at the documentation :)
BUT, if we didn't have a reference to out previous view, does anyone know a way we could get the last subview?