– (void)didLoadImageInBackground:(UIImage *)image {

[currentImage setImage: image];

CGFloat totalWidth = self.view.frame.size.width;
CGFloat totalHeight = self.view.frame.size.height;

CGImageRef imgRef = image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);

if(width>totalWidth)
{
height = (height * totalWidth) / width;
width = totalWidth;
}

if(height > totalHeight)
{
width = (width * totalHeight) / height;
height = totalHeight;
}

[currentImage setFrame:CGRectMake(0, 0, width, height)];
currentImage.center = CGPointMake(totalWidth/2, self.view.center.y);
}

Advertisements