iOS开发学习iOS DeveloperiOS学习开发

Bounds和frame

2017-05-27  本文已影响7人  BEYOND黄

frame:以父控件左上角为原点,描述可视范围。

bounds:以自己的左上角为原点,描述可视范围在内容的区域。所有的控件都是加在内容里,修改内容原点。

相对性:可视范围相对于父控件位置不变,相对于内容区域变。

UIView*AV = [[UIViewalloc]initWithFrame:CGRectMake(50,50,200,200)];

AV.backgroundColor=[UIColorblueColor];

[self.viewaddSubview:AV];

_AV= AV;

UISwitch*sv = [[UISwitchalloc]init];

[AVaddSubview:sv];

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent*)event{

CGRectbounds =_AV.bounds;

bounds.origin.y+=10;

_AV.bounds= bounds;

}

上一篇 下一篇

猜你喜欢

热点阅读