frame:以父控件左上角為原點(diǎn),描述可視范圍。
bounds:以自己的左上角為原點(diǎn),描述可視范圍在內(nèi)容的區(qū)域。所有的控件都是加在內(nèi)容里,修改內(nèi)容原點(diǎn)。
相對(duì)性:可視范圍相對(duì)于父控件位置不變,相對(duì)于內(nèi)容區(qū)域變。
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;
}