Skip to content

Instantly share code, notes, and snippets.

@jlcampana
Created January 2, 2013 12:01
Show Gist options
  • Save jlcampana/4434083 to your computer and use it in GitHub Desktop.
Save jlcampana/4434083 to your computer and use it in GitHub Desktop.
Cambiar aspect ratio para fotos según pantalla
CGSize s = originalImage.size;
CGSize s2 = [UIScreen mainScreen].bounds.size;
CGSize s3 = CGSizeMake(roundf(s.width / s2.width), roundf(s.height/s2.height));
CGFloat factor = fmax(s3.width, s3.height);
// Divide the size by the greater of the vertical or horizontal shrinkage factor
s.width = roundf(s.width /factor);
s.height = roundf (s.height / factor);
UIImage *image = [self scaleImage:originalImage ToSize:s];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment