我试图在UIViewController的底部对齐imageView,但在iPhone 5模拟器上它没有在底部对齐。
我试着把imageView放在storyboard的底部,它是正确对齐的,所以我想我的代码中遗漏了什么。
任何建议吗?
谢谢,e .
imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 416, 320, 64)];
[imageView setContentMode:UIViewContentModeScaleToFill];
imageView.autoresizingMask=UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview:imageView];
懂了,用了
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[xmlView]|"
options:0
metrics:0 views:NSDictionaryOfVariableBindings(xmlView)]];
像这样设置帧大小:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.size.height-64, 320, 64)];
[imageView setContentMode:UIViewContentModeScaleToFill];
[self.view addSubview:imageView];