Ross Sullivan Ross Sullivan - 1 year ago 147
iOS Question

How to programmatically set view to the front/back?

Im working on an application that uses UIViews as backgrounds to text. I've put the Views behind the text in the story board but for some reason some still seem to be in front of the text. Is there a way to send these view to the back programmatically? Here is a screenshot of what im talking aboutPicture

Answer Source

You can use on of these two:

- (void)bringSubviewToFront:(UIView *)view;
- (void)sendSubviewToBack:(UIView *)view;

view.sendSubviewToBack(subview) and view.bringSubviewToFront(subview)

  • bringSubviewToFront: Moves the specified subview so that it appears on top of its siblings.
  • sendSubviewToBack: Moves the specified subview so that it appears behind its siblings.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download