Bring previously added view to front

Busu picture Busu · Aug 7, 2013 · Viewed 8k times · Source

My problem is the following:

I have a view and to that view I add 3 subViews(view1,view2,view3) in that order. The views slightly overlap. I want to bring the first view to the top but I just can't get it to work.

I tried adding the views with insertSubview:atIndex: and giving view1 a larger index and I tried using addSubview: and then bringSubviewToTop but nothing seems to work.

Any ideas?

P.S. I can't add the views in a different order. They have to be added in this order.

Answer

Adam Richardson picture Adam Richardson · Aug 7, 2013

bringSubviewToFront should work, just make sure you're using it correctly. The usage is.

[parentView bringSubviewToFront:view1];