Kuldeep Tanwar
Kuldeep Tanwar

Reputation: 3526

How to bring subview to front in interface builder without changing its position

I want to ask a simple question how can I temporary bring a subview to front to view its element without changing its position by dragging and dropping. The problem i face all the time is i forgot to put the views back to there position and that causes lot of trouble specially if you are working on the view that have large number of subviews.

Question : Is there any shortcut or any functionality that can show the view temporary without dragging, changing its frame or making any changes in its hierarchy.

For a view controller like this :-

enter image description here

Upvotes: 1

Views: 2214

Answers (2)

Mendo
Mendo

Reputation: 163

FYI, for those who are wondering, the view closest to the bottom of the list (on the left) will show in the front. So in the case below, view 'a' will be in front of 'b' and 'b' will be in front of 'c'

XIB:
XIB

Upvotes: 7

Stonz2
Stonz2

Reputation: 6396

If you need your views to be readily accessible for viewing/editing without having to rearrange them, I would actually recommend breaking them out into their own view and then stitching them together in the correct order in your code. This will ensure that all elements will be put in the proper order and will always be easily editable. Something like this:

Interface Builder

And then in your code, in somewhere like viewDidLoad:

[self.view addSubview:view2];
[self.view addSubview:view3];

Upvotes: 2

Related Questions