Objective-c将子视图添加到视图的底部

Mat*_*age 7 objective-c subview ios

有没有办法在其视图的"底部"添加子视图,如使用图层时z = 0?我需要这个,因为当我产生物体时,它们需要在另一张照片下,而不是在上面.

Nic*_*tto 19

UIView的子视图的排序方式是数组的最后一个是最前面的一个,然后是第一个(索引0)是后面的那个.因此,要将其插入"底部",这样做就足够了:

[view insertSubview:aView atIndex:0]
Run Code Online (Sandbox Code Playgroud)


mvd*_*vds 2

sendSubviewToBack:

Moves the specified subview so that it appears behind its siblings.
- (void)sendSubviewToBack:(UIView *)view
Run Code Online (Sandbox Code Playgroud)

来源:http ://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html