self.view addSubview图层

eri*_*ell 1 uiview addsubview ios

使用时

[self.view addSubview:foo];
Run Code Online (Sandbox Code Playgroud)

有没有办法指定对象将去哪个层?即是否可以不添加对象到所有对象上方的视图层顶部?我使用addSubview来动态添加视图对象,但是如果你知道我的意思,我希望它们中的一些不在堆栈顶部.如果我的解释不可理解,我可以详细说明.

Mat*_*ecu 22

你可以使用其中一个函数(全部来自UIView),具体取决于你想做什么

– bringSubviewToFront:
– sendSubviewToBack:
– insertSubview:atIndex:
– insertSubview:aboveSubview:
– insertSubview:belowSubview:
- exchangeSubviewAtIndex:withSubviewAtIndex:
Run Code Online (Sandbox Code Playgroud)

(名字的行为非常明显).