我正在为 iPhone 5 屏幕更新我的应用程序。听起来 setAutoresizingMask 可以很好地用于定位对象(而不是硬编码 alt 坐标),但我似乎无法让它工作。
我的应用程序不旋转,我只想将此图像加载固定到底部,用于 480 或 568 高屏幕。
这是我的简单尝试。将非常感谢您的建议。谢谢。
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.autoresizesSubviews = YES;
UIImage *getImg = [UIImage imageNamed:@"footer.jpg"];
UIImageView *footer = [[UIImageView alloc] initWithImage:getImg];
[footer setFrame:CGRectMake(0,0,302,50)];
[footer setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin];
[self.view addSubview:footer];
}
(我相信这个 setAutoresizingMask 应该将图像设置为左下角。)