Method: UIImage#in_rect

Defined in:
lib/sugarcube-image/uiimage.rb

#in_rect(rect) ⇒ UIImage

This method is used to crop an image. Scale (retina or non-retina) is preserved.

Parameters:

  • rect (CGRect)

    the portion of the image to return

Returns:



57
58
59
60
61
62
# File 'lib/sugarcube-image/uiimage.rb', line 57

def in_rect(rect)
  imageRef = CGImageCreateWithImageInRect(self.CGImage, rect)
  sub_image = UIImage.imageWithCGImage(imageRef, scale:self.scale, orientation:self.imageOrientation)

  return sub_image
end