iOS – Objective-C | Scale Image Size to Fullscreen

You may need to use the following imports (if needed, update your pod file accordingly)

#import <UIImageView+WebCache.h>
#import <UIView+CBFrameHelpers.h>

Using UIImageView

 // UIImageView * flyerImageView; define in .h file and connect to your imageview in .xib file
 UIImage *_image = [UIImage imageNamed:@"some_image_name.png"];
 [flyerImageView setImage:_image];
CGSize actualSize = image.size;
 float scale = flyerImageView.frame.size.width / (float)actualSize.width;
CGSize newSize = CGSizeApplyAffineTransform(actualSize, CGAffineTransformMakeScale(scale, scale));
         if (newSize.height > 290) {
             newSize.height = 290;
 float increment;
increment = newSize.height - flyerImageView.frame.size.height;
dispatch_async(dispatch_get_main_queue(), ^{
       [flyerImageView setSizeFromSize:newSize];

Using UIImage

UIImage *_image = [UIImage imageNamed:@”some_image_name.png”];
UIImage *big = [UIImage imageWithCGImage:_image.CGImage scale:0.1 orientation:_image.imageOrientation];

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s