bounds frame anchor position 的区分
来源:互联网 发布:淘宝店铺怎么重新激活 编辑:程序博客网 时间:2024/05/15 08:34
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 150 , 200)];
UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 150 , 200)];
UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(100, 100,150 , 200)];
// UIView *view3 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 150 , 200)];
// view3.backgroundColor = [UIColor blueColor];
view1.backgroundColor = [UIColor redColor];
view2.backgroundColor = [UIColor greenColor];
view.backgroundColor = [[UIColor redColor]colorWithAlphaComponent:0.3];//设置颜色和透明度
view.layer.backgroundColor = [[UIColor grayColor]colorWithAlphaComponent:0.5].CGColor;
// center:描述当前视图的中心点在其父视图中的位置。
// view.center = CGPointMake(200, 200);
/* frame的bounds属性和anchor point属性都是针对一个frame自身而言的,而frame的position属性,是一个frame相对于它的parent frame而言的,它指定了这个frame在它的parent frame坐标系中相对于parent frame bounds左上角的位置。*/
// view.layer.position = CGPointMake(320/2, 480/2);
/* frame的大小是由bounds属性决定的,由bounds框框起来的范围是一个frame真正可以显示出来的范围 */
// view.layer.bounds = CGRectMake(0, 0, 100, 100);
/* bounds (0,0,100,100) --> (0,0,200,200)本地坐标系统原点往左往上分别50。center不变,效果是按照中心放大view bounds(0,0,100,100) --> (100,100,100,100)本地坐标系统原点往左往上分别100。center不变,没有可视效果变化(但是本地坐标系统的原点已经改变) 结论: bounds属性影响到本地坐标系统的原点。需要注意
*/
// view.bounds = CGRectMake(100,100, 300, 300);
/*anchorPoint属性,值域是0~1,是个比例值,这个图形是各种图形变换的坐标原点同时会更改layer的position的位置,它的缺省值是(0.5,0.5),即在layer的中央
anchorpoint可以在bounds范围内移动,它的值从(0.0,0.0)到(1.0,1.0)默认值为(0.0,0.0),也就是bounds的左上角点 anchor point点是一个frame在旋转、平移、缩放时的参考点,frame在做旋转、缩放、平移等变换时就是以anchor point点为中心点。 center是父视图
*/
view.layer.anchorPoint = CGPointMake(0.5f,0.5f);//
view1.layer.anchorPoint = CGPointMake(0.f,0.f);//绿色向上
view2.layer.anchorPoint = CGPointMake(1.0f,1.0f);//红色向下
// view3.layer.anchorPoint = CGPointMake(1.0f,0.f);
NSLog(@"view %f,%f,%f,%f",view.frame.origin.x,view.frame.origin.y,view.frame.size.width,view.frame.size.height);
NSLog(@"layer %f,%f,%f,%f",view.layer.frame.origin.x,view.layer.frame.origin.y,view.frame.size.width,view.frame.size.height);
NSLog(@"anchorPoint %f,%f",view2.layer.anchorPoint.x,view2.layer.anchorPoint.y);
NSLog(@"view layer bounds %f , %f , %f, %f",view1.layer.bounds.origin.x,view1.layer.bounds.origin.y,view1.layer.bounds.size.width,view1.layer.bounds.size.height);
NSLog(@"view bounds %f , %f , %f, %f",view2.bounds.origin.x,view2.bounds.origin.y,view2.bounds.size.width,view2.bounds.size.height);
NSLog(@"view position %f ,%f",view2.layer.position.x,view2.layer.position.y);
// view.layer.cornerRadius = 50;//根据修改的值的大小其位置会改变其图层的边角为圆型
// view.layer.shadowOffset = CGSizeMake(100, 100);
//
// view.layer.shadowColor = [UIColor redColor].CGColor;
[self.view addSubview:view1];
[self.view addSubview:view2];
[self.view addSubview:view];
// [self.view addSubview:view3];
[view.layer setNeedsDisplay];
- bounds frame anchor position 的区分
- venus中frame的position、bounds和anchor point三者的关系。
- ios CALayer的Frame,bounds,position,anchorPoint
- frame、bounds、center、anchorPoint、position
- 图层的frame、bounds、position和anchorPoint关系
- position与frame bounds anchorPoint的深入理解
- 理解frame、bounds、center、position、anchorPoint
- frame,bounds的区别
- 综述iOS视图的frame、bounds、center、position、anchorPosition等与位置、大小有关的属性
- frame 和bounds 的区别
- bounds和frame的区别
- bounds和frame的差别
- bounds和frame的差别
- Frame与Bounds的区别
- frame、bounds、center的区别
- frame与bounds的差别
- frame与bounds的区别
- UIView的frame与bounds
- Javaweb开发防止用户重复登录
- 哈希表之二----链地址法创建哈希表
- Myeclipse中左边的项目目录调没了,怎么再让它显示出来
- 关于Struts的Action
- Android学习笔记(十三)——碎片(一)
- bounds frame anchor position 的区分
- 嵌入式平台上的人脸检测系统(简单总结)
- Floyd求字典序最小的路径
- 【明星学员】一步步超越自己,挑战自己-上海传智学员崔默
- 多备份:云端数据物流平台为企业提供云备份服务
- Cathe和Buffer的区别
- 换行符和回车符的区别
- 分享 调整“quiver”箭头大小的程序
- 【从零之六&完结】android口语对话系统(RavenClaw java版 含全部源码)