Reputation: 91
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
Reputation: 5909
in objective-c its like this
[imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
OR
in interface builder, click the arrows so it looks like this
You can lookup the swift syntax! hope this works
Upvotes: 3