Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move the UIView to the "bottom" so that the next UIView displays?

I want to "remove" a UIView from a superview and add it again at the end... but at the "bottom" of the rest of the UIviews that belong to the superview.

Is this possible?

Any help is very appreciated!

like image 960
rksprst Avatar asked Oct 26 '08 22:10

rksprst


2 Answers

Hmmm...

- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;

Might be what you're after? Alternatively -

- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;

Though you could avoid removing the view all together (if you don't need to for any other reason) by calling sendSubviewToBack: -

- (void)sendSubviewToBack:(UIView *)view;
like image 116
Max Stewart Avatar answered Oct 01 '22 09:10

Max Stewart


I don't really understand what you mean by bottom. You can use: [view removeFromSuperview]; to remove it ( make sure you retain it ( [view retain]; ) before you do that and release [view release]; when it's no longer needed.

Another thing you can do if you want one view to be behind another view is to set its "zPosition" ( view.layer.zPosition = X; )

if a View has a zPosition that is bigger than another views zPosition it will appear on top of the other view.

like image 38
2 revs, 2 users 77% Avatar answered Oct 01 '22 10:10

2 revs, 2 users 77%