/*
UIView:
坐标相关属性:frame(相对父视图而言)位置 大小 bounds(以自身为参考坐标 起始点(0,0))
center 中心点(相对父视图而言)
UIView只能有一个父视图 但可以有多个子视图
*/
UIView * v = [[UIView alloc] initWithFrame:CGRectMake(0, 20, 200, 200)];
v.backgroundColor = [UIColor orangeColor];
[self.window addSubview:v];
[v release];
NSLog(@"%f %f",v.center.x,v.center.y);
UIView * v1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
v1.backgroundColor = [UIColor redColor];
[v addSubview:v1];
[v1 release];
NSLog(@"%f %f",v1.center.x,v1.center.y);
// v1 frame 10 10 80 80 bounds 0 0 80 80 center 50 70
// NSLog(@"%@",self.window.subviews);
// NSLog(@"%@",v.subviews);
// 获取当前视图的父视图
NSLog(@"super view is %@",v1.superview);
// 获取当前视图的子视图
NSLog(@"subViews is %@",v1.subviews);
// 将某个视图隐藏
// v1.hidden = YES;
// 将当前父视图上 超出父视图边界的子视图部分剪裁
v.clipsToBounds = YES;
// 将子视图从父视图中移除
CustomView * v2 = [[CustomView alloc] initWithFrame:CGRectMake(150, 150, 150, 150)];
v2.backgroundColor = [UIColor greenColor];
[self.window addSubview:v2];
/*
removeFromSuperview:将子视图从父视图当中移除,同时将它从响应者链中移除
会对该对象响应者链之下的所有子视图做一次release操作
release:仅仅只对对象的引用计数减1
*/
[v2 release];
CustomView * v3 = [[CustomView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
v3.backgroundColor = [UIColor blackColor];
[v2 addSubview:v3];
[v3 release];
// [v2 release];
[v2 removeFromSuperview];