Charls Pico
Charls Pico

Reputation: 91

Change ImageView Size Xcode

I have a problem changing an UIImageView's size. The thing is that I want to make an Universal App and I just can't make the UIImageView to get bigger when the detected device is an iPad.

Right now I'm using this code:

 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)
 }

The thing is, it does changes the color but it doesn't change the image size. So how can I manage to change the size? And I don't want to use auto layout, I want to use code. Thanks!

Upvotes: 0

Views: 3156

Answers (1)

KDaker
KDaker

Reputation: 5909

in objective-c its like this

 [imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

OR

in interface builder, click the arrows so it looks like this

enter image description here

You can lookup the swift syntax! hope this works

Upvotes: 3

Related Questions