iOS Guides | Samples

MonoTouch.UIKit.UIImage.CreateResizableImage Method

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

Syntax

[MonoTouch.Foundation.Export("resizableImageWithCapInsets:")]
[MonoTouch.ObjCRuntime.Availability(Introduced=MonoTouch.ObjCRuntime.Platform.iOS_5_0)]
[MonoTouch.ObjCRuntime.ThreadSafe]
public virtual UIImage CreateResizableImage (UIEdgeInsets capInsets)

Parameters

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

Returns

A new image object with the specified cap insets

Remarks

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 http://openradar.appspot.com/11411000 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.

Requirements

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