.
Hello,
In Interface builder it really easy to set the order of items, as in the layers by dragging them one above the other.
I am not being successful to replicate that in code.
What is the line I need to add to have a similar effect?
Cheers
.
Hello,
In Interface builder it really easy to set the order of items, as in the layers by dragging them one above the other.
I am not being successful to replicate that in code.
What is the line I need to add to have a similar effect?
Cheers
To quote another post, there are many useful methods for this exact purpose:
@property(nonatomic,readonly) UIView *superview;
@property(nonatomic,readonly,copy) NSArray *subviews;
- (void)removeFromSuperview;
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;
- (void)addSubview:(UIView *)view;
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
- (void)bringSubviewToFront:(UIView *)view;
- (void)sendSubviewToBack:(UIView *)view;
Their names are fairly self explanatory. Of particular interest to you might be insertSubview:AtIndex, insertSubview:belowSubview (or above), as well as the bringSubviewToFront and sendSubviewToBack. These will allow you to build your view without having to add them in any specific order.
Just subview them in reversed order (if you want it on top, subview last). There are also functions to insert subview before or after a reference subview.