iOS Guides | Samples

MonoTouch.UIKit.UIImage.CreateResizableImage Method

Creates a new image from the current instance and applies the specified cap insets.


public virtual UIImage CreateResizableImage (UIEdgeInsets capInsets)


This argument lets you specify the top, left, bottom and right inset (the sizes of your images).


A new image object with the specified cap insets


Use this method to turn an existing UIImage into a UIImage that can be resized with the specified parameters. The region described by the UIEdgeInsets will be stretched when rendered. The corners will be kept intact, the borders will stretch along their side and the center will be tiled.

There are some scenarios where this method can crash in some versions of the operating system. See for more details. If you experience those crashes, you should try to replace this with the UIImage.StretchableImage method instead.

For best performace, it is best to make the region that stretches 1x1 pixels.

Consider the following image, the capInsets specify these borders:

This can be used from a background thread.


Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: