视图顺序
[self.view insertSubview:girlView belowSubview:bottomView];//把girlView插入到bottomView后面
[self.view insertSubview:girlView aboveSubview:bottomView];//把girlView插入到bottomView前面
[self.view insertSubview:girlView atIndex:0];//把girlView插入到0层
[self.view bringSubviewToFront:girlView];//把girlView移到最前
[self.view sendSubviewToBack:girlView];//把girlView移到最后
如果想调用某个类的某个方法可以写成这样,这个方法来自NSObject类
performSelector:
performSelector:withObject:
performSelector:withObject:withObject:
实际调用
[self performSelector:@selector(displayViews) withObject:nil afterDelay:1.0f];
有三个方法分别是
[self.view superview]
//所有子视图
[self.view subviews]
//自身的window
self.view.window ```
`UIView提供了大量管理视图的方法`
//加一个视图到一个视图里面
addSubview:
//将一个视图移到前面
bringSubviewToFront:
//将一个视图推送到背后
sendSubviewToBack:
//把视图移除
removeFromSuperview
//插入视图 并指定索引
insertSubview:atIndex:
//插入视图在某个视图之上
insertSubview:aboveSubview:
//插入视图在某个视图之下
insertSubview:belowSubview:
//交换两个位置索引的视图
exchangeSubviewAtIndex:withSubviewAtIndex:
`视图回调`
//当加入视图完成后调用
(void)didAddSubview:(UIView *)subview
//当视图移动完成后调用
(void)didMoveToSuperview
//当视图移动到新的WINDOW后调用
(void)didMoveToWindow
//在删除视图之后调用
(void)willRemoveSubview:(UIView *)subview
//当移动视图之前调用
(void)didMoveToSuperview:(UIView *)subview
//当视图移动到WINDOW之前调用
(void)didMoveToWindow
` 给UIView设置标记和检索视图`
myview.tag = 1001;
[self.view viewWithTag:1001];
(UILable *)[self.view.window viewWithTag:1001];
网友评论