ios change subview index runtime
Just insert at new index:
[containerView insertSubview:subview atIndex:newIndex];
Swift versions for easy copy paste:
insertSubview(myView1, belowSubview: myView2)
insertSubview(myView2, aboveSubview: myView1)
insertSubview(view: myView1, atIndex: 1)
sendSubviewToBack:
and bringSubviewToFront:
are the methods you are looking for. Another possibility is exchangeSubviewAtIndex:withSubviewAtIndex:
if you want to exchange the layer of two views.