ios框架和边界 - CGRectMake是屏幕外的

时间:2012-07-20 08:42:17

标签: ios ipad

在iPad上,当人像是在屏幕外时,为什么这甚至以纵向启动?

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIView* imageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    blue.backgroundColor = [UIColor blueColor];
    [[self view] addSubview:imageView];

我被告知根视图的框架在纵向和横向上始终相同: - 纵向框架orign(x i代表UIView的外观)
X0
00
00

横向框架orign:
000
X00

但是为什么CGRectMake(0,0 ..没有在画像右上角?

提前致谢

1 个答案:

答案 0 :(得分:0)

旋转设备时,边界和框架可能会发生变化。我们以单视图应用程序模板为例,添加方向支持并在iPhone上运行它。纵向:

bounds = (0, 0, 320, 460) // 460 compensates for 20p status bar
frame = (0, 20, 320, 460) // status bar adjustment
x0
00
00

在风景中:

bounds = (0, 0, 480, 300) // now 20p is taken from "height"
frame = (20, 0, 300, 480) // status bar adjustment
x00
000

无论方向如何,原点始终位于左上角。