1

I'm setting an image to a UIButton like this:

[fView.coverImage.imageView setImageWithURLRequest:[NSURLRequest requestWithURL:MYURL] placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
                        fView.coverImage.imageView.contentMode = UIViewContentModeScaleAspectFit;
                        [fView.coverImage setImage:image forState:UIControlStateNormal];

}];

The image in question has a height of 400px. Most of the time this works fine, but on an iPad Retina screen, the UIButton has a height of around 600px. Despite the content mode I have specified, the image will not scale up beyond 400px. How can I make the image scale up beyond it's original size?

James Harpe
  • 4,315
  • 8
  • 47
  • 74

1 Answers1

0

Try to use this in your block:

[ImageManipulation scale:image toSize:fView.coverImage.imageView.frame];

"ImageManipulation" is my class name, call it however you like..

And this is the method i use to scale:

+ (UIImage*)scale: (UIImage*)image toSize: (CGSize)size {
    UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return scaledImage;
}

Hope this helps

MCMatan
  • 8,623
  • 6
  • 46
  • 85