tags:

views:

2242

answers:

3

Hello All:

What is the difference between addSubview and insertSubView methods when a view is added programmatically?

Thanks

Ashwani

+2  A: 

Using insertSubView: you can specify the index, which determines z-order of views. A view with a higher index lies above those with lower indices.

Nikolai Ruhe
Thanks, I wanted to is there specific difference in uses of these two functions
Ashwani K
Aside from the specific difference I described in my answer, there is none.
Nikolai Ruhe
+3  A: 

I don't think there is a difference. addSubview: is simple a convenient method for

[view insertSubview:aView atIndex:[view.subviews count]]
sliver
+3  A: 

The only difference is in where the view is added: whether it is the frontmost view (addSubview:), or it is before the 5th subview, (insertSubview:atIndex:) or if it is immediately behind another subview (insertSubview:aboveSubview:).

mahboudz