开发者

iPhone, Order UIImages Programmatically

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜