Method: UIImage#scale_to

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

#scale_to(new_size, background: background) ⇒ UIImage

Scales an image to fit within the given size. Its current aspect ratio is maintained, but the image is padded so that it fills the entire area. If the image is too small, it will be scaled up to fit. If you specify a background that color will be used, otherwise the background will be transparent.

Parameters:

  • new_size (CGSize)

    Maximum dimensions of desired image. The returned image is guaranteed to fit within these dimensions.

  • background (UIColor) (defaults to: background)

    Color to fill padded areas. Default is transparent.

Returns:



217
218
219
# File 'lib/sugarcube-image/uiimage.rb', line 217

def scale_to(new_size)
  scale_to(new_size, background:nil)
end