Skip to content

Instantly share code, notes, and snippets.

View jyliang's full-sized avatar

Jason Liang jyliang

  • New York, NY
  • 13:27 (UTC -04:00)
View GitHub Profile
@jyliang
jyliang / UIImageCrop
Created March 4, 2014 20:23
UIImageCrop Utility
#define DEGREES_RADIANS(angle) ((angle) / 180.0 * M_PI)
- (UIImage*) UIImageCrop:(UIImage *)img withRect:(CGRect)rect {
CGAffineTransform rectTransform;
switch (img.imageOrientation)
{
case UIImageOrientationLeft:
rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(DEGREES_RADIANS(90)), 0, -img.size.height);
break;
case UIImageOrientationRight: