父子控件之间的操作
父控件管理众多子控件
- 父控件中的所有子控件
NSArray *subsArray = [superview subviews]; // 返回一个数组,一个父控件可以有多个子控件
- 子控件的父控件
[subview superview]; // 子控件只有一个父控件
- 子控件从父控件中删除
[subview removeFromSuperView]; // view1从父控件中删除
- 一个往一堆子控件扎的子控件
- 往某个位置插入
[superview insertSubview:sub atIndex:index];
- 插在某个子视图的下面
[superview insertSubview:sub belowSubview:sub2];
- 插在某个子视图的上面
[superview insertSubview:sub aboveSubview:sub2];
- 插在所有子控件上面
[superview bringSubviewToFront:sub];
- 插在所有子控件下面
[superview sentSubviewToBack:sub];
- 往某个位置插入