Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Forked from anonymous/SGCard InitWithImage
Created February 8, 2013 14:42
Show Gist options
  • Save jcromartie/4739422 to your computer and use it in GitHub Desktop.
Save jcromartie/4739422 to your computer and use it in GitHub Desktop.
- (id)initWithImage:(UIImage *)image
{
self = [super init];
if (self) {
[self setClipsToBounds:YES];
[self setAutoresizesSubviews:YES];
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
CGImageRef originalImage = [image CGImage];
_image = image;
_image = [[UIImage alloc] initWithCGImage:originalImage scale:imageScale orientation:image.imageOrientation];
_imageView = [[UIImageView alloc] initWithImage:_image];
[_imageView setImage:_image];
[_imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[self addSubview:_imageView];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment