2013-04-20 98 views
2

我想在我的UIViewController的底部对齐imageView,但是在iPhone 5模拟器上它不在底部对齐。UIImageView以编程方式自动调整大小

我试图把一个imageView放在故事板的底部,它正确对齐,所以我想我错过了我的代码中的东西。

有什么建议吗?

谢谢, e。

imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 416, 320, 64)]; 
[imageView setContentMode:UIViewContentModeScaleToFill]; 
imageView.autoresizingMask=UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin; 
[self.view addSubview:imageView]; 
+0

你想要这个图像和屏幕一样高,是吗?你在使用AutoLayout,b.t.w?吗? – 2013-04-20 21:24:16

+0

我希望图像位于屏幕的底部,其高度为64.自动刷新选项已启用! – 2013-04-20 21:57:05

回答

1

得到它,使用

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[xmlView]|" 
                    options:0 
                    metrics:0 views:NSDictionaryOfVariableBindings(xmlView)]]; 
1

设置帧大小是这样的:

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]; 

希望这会有所帮助。

相关问题