Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CGRectMake坐标指的是哪个坐标_Ios - Fatal编程技术网

Ios CGRectMake坐标指的是哪个坐标

Ios CGRectMake坐标指的是哪个坐标,ios,Ios,我们使用CGRectMake设置宽度、高度以及x和y坐标,但x和y指的是哪个坐标 坐标是根视图的坐标,如果是,则创建一个子视图,然后添加此坐标 按钮,然后它将引用哪个坐标哪个坐标 UIButton *roundRectButton = [UIButton buttonWithType: UIButtonTypeRoundedRect]; [roundRectButton setFrame:CGRectMake(60, 50, 200, 40)]; UIView坐标系指其superview,

我们使用CGRectMake设置宽度、高度以及x和y坐标,但x和y指的是哪个坐标 坐标是根视图的坐标,如果是,则创建一个子视图,然后添加此坐标 按钮,然后它将引用哪个坐标哪个坐标

UIButton *roundRectButton = [UIButton buttonWithType:

UIButtonTypeRoundedRect];

[roundRectButton setFrame:CGRectMake(60, 50, 200, 40)];

UIView坐标系指其superview,其原点位于superview的左上角。 如上所述

UIKit中的默认坐标系的原点位于左上角,并且具有从原点向下和向右延伸的轴。坐标值使用浮点数表示,允许内容的精确布局和定位,而不考虑基本屏幕分辨率。图1-4显示了相对于屏幕的坐标系。除了屏幕坐标系外,窗口和视图还定义自己的局部坐标系,允许您指定相对于视图或窗口原点的坐标,而不是相对于屏幕的坐标


因此,您的uibutton坐标系将引用其超级UIView。

当您设置
帧时,这意味着您相对于其超级视图对其进行定位,当您使用
边界时,这意味着您使用设备的真实(x,y)坐标对其进行定位


在这里,您正在设置视图的框架(即UIButton),这样您就可以根据其
父视图对其进行定位

始终引用(直接)父视图。小心理解有边界的差异!添加子视图时,子视图位于为其框架设置的坐标处