1.获得字控件在父控件中层的索引
//获得子控件数组
NSArray *subViews = self.subviews;
//获得字控件在父控件中层的索引
NSInteger rearIndex = [subViews indexOfObjectIdenticalTo:_rearView];
2,常用设置子控件层的方法
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;//根据子控件层索引添加字控件到父控件上
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2; //根据子控件层的索引交换子控件的位置
- (void)addSubview:(UIView *)view;//添加子控件到父控件上,默认添加到最上层。索引最大的
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;//添加子控件,在另一个子控件的下面
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;//添加子控件,在另一个子控件的上面
- (void)bringSubviewToFront:(UIView *)view; //将子控件放到父控件的最上层。
- (void)sendSubviewToBack:(UIView *)view;//将子控件放到父控件的最下层