更改 ImageView 大小 Xcode

Change ImageView Size Xcode

我在更改 UIImageView 的大小时遇到​​问题。问题是我想制作一个通用应用程序,但当检测到的设备是 iPad.

时,我无法让 UIImageView 变大

现在我正在使用这个代码:

 if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone)
 {
     self.image.backgroundColor = UIColor.greenColor()
 }
 else if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad)
 {
     self.image.backgroundColor = UIColor.blueColor()
     self.image.frame = CGRectMake(0, 0, 768, 1024)
 }

事实是,它确实改变了颜色,但没有改变图像大小。那么我怎样才能设法改变尺寸呢?而且我不想使用自动布局,我想使用代码。谢谢!

在objective-c中是这样的

 [imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

在界面生成器中,单击箭头使其看起来像这样

您可以查找 swift 语法!希望这有效