Objective c ChildView没有';无法维护其父视图框架

Objective c ChildView没有';无法维护其父视图框架,objective-c,Objective C,希望大家都好。伙计们,我有一个情况,我有一个uiview和uibutton,如下所示: UIView*containerView=[[UIView alloc]initWithFrame:CGRectMake(0200,self.view.frame.size.width,70)]; containerView.backgroundColor=[UIColor whiteColor]; [self.view addSubview:containerView]; UIButton*button=

希望大家都好。伙计们,我有一个情况,我有一个uiview和uibutton,如下所示:

UIView*containerView=[[UIView alloc]initWithFrame:CGRectMake(0200,self.view.frame.size.width,70)];
containerView.backgroundColor=[UIColor whiteColor];
[self.view addSubview:containerView];
UIButton*button=[UIButton button类型:UIButtonyPeroundRect];
button.backgroundColor=[UIColor redColor];
[按钮添加目标:自我操作:@选择器(设置按下:)用于控制事件:UIControlEventTouchUpInside];
UIImage*image=[UIImage ImageName:@“settings_button.png”];
[按钮设置图像:图像状态:uicontrol状态高亮显示和uicontrol状态正常和uicontrol状态选定];
button.frame=CGRectMake(0,0,40,40);
button.center=containerView.center;

[containerView添加子视图:按钮]首先,当您更改视图的
中心
属性时,
框架
属性将自动更改,因此您只需设置按钮中心:

button.center = CGPointMake(containerView.frame.size.width  / 2, 
                              containerView.frame.size.height / 2);
现在,无论何时更改中心属性,都需要手动告诉视图使用
setNeedsDisplay
重新绘制自身:

[button setNeedsDisplay]

最后,框架和边界之间的差异框架定义了相对于父视图的位置和大小,而边界描述了框架内部(或外部)的绘图区域。

还有谁能告诉我self.view.bounds.size.width和self.view.frame.size.width之间的差异?