Essentially I would like to add a UIImage programmatically to my interface, using:
[[self view] addSubview: myImage]
However, I would like to add the image BEHIND an existing image already开发者_如何学Go present in the interface builder. Is there a method to accomplish this?
Use
[[self view] insertSubview:myImage atIndex:i]
i specifies the z index, where a higher index will be above a view with a lower index, so if i = 0 the view will be at the bottom.
UIView has a number of methods for inserting subviews into different places.
If you know which subview you want it to go behind you could use:
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview
Or if you know the index try:
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
If you make the existing image an IBOutlet you could use the first method I mentioned.
精彩评论