iOS第一天
iPhone4 3.5寸 不是retina屏 32位系统 320×480 {{0, 0}, {320, 480}}
iPhone4S 3.5寸 retina屏 32位系统 640×960{{0, 0}, {320, 480}}
iPhone5/5c 4寸屏 retina屏 32位系统 640×1136 {{0, 0}, {320, 568}}
iphone5s 4寸 retina屏 64位系统 640×1136{{0, 0}, {320, 568}}
iphone6/6s 4.7寸屏 retina屏 64位系统 750×1334{{0, 0}, {375, 667}}
iPhone6 plus/iphone6s plus retina屏 64位系统 1242×2208{{0, 0}, {414, 736}}
4寸\4.7寸\5.5寸 比例都是16:9
prepo 马克曼
CGRect :CGPoint & CGSize origin size
CGPoint: x & y
CGSize: width heigth
Xcode 虚拟器bounds
{{0, 0}, {375, 667}
frame是以父视图为参考系
-(CGRect)frame{
return CGRectMake(self.frame.origin.x,self.frame.origin.y,self.frame.size.width,self.frame.size.height);
}
frame为自己新定义区域范围
frame: 该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统)
bounds是以自身为参考系
-(CGRect)bounds{
return CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
}
bounds是原定范围
bounds:该view在本地坐标系统中的位置和大小。(参照点是,本地坐标系统,就相当于ViewB自己的坐标系统,以0,0点为起点)
无法直接修改结构体里面的值
全局结构体转换成局部变量,修改局部变量。
无法直接操作全局变量的值
代码创建
//定义一个rect(横坐标,纵坐标,长度,宽度)UIScreen
CGRect rect = [UIScreen mainScreen].bounds;
NSLog(@"%@",NSStringFromCGRect(rect));
//创建UIWindow的大小
self.window = [[UIWindow alloc]initWithFrame:rect];
//设置window的背景色
self.window.backgroundColor = [UIColor brownColor];
//将window升级为Kwindow,并且可视
[self.window makeKeyAndVisible];
//添加主视图控制器
ViewController* vc = [[ViewController alloc]init];
self.window.rootViewController = vc;
UIView* v= [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
v.backgroundColor = [UIColor blueColor];
[self.view addSubview:v];
根据tag值找到子视图
UIView* v = [self.view viewWithTag:100];
添加子视图
[self.view addSubview:v];
删除子视图
[v2 removeFromSuperview];
计时器
[NSTimer scheduledTimerWithTimeInterval: 0.5 target:self selector:@selector(addColorBlock) userInfo:nil repeats:YES];