views:

2713

answers:

2

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!

+9  A: 

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;
Max Stewart
Thank you!!! - (void)sendSubviewToBack:(UIView *)view; was exactly what I was looking for!
rksprst
A: 

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.

Gu1234