Edytuj

Udostępnij za pośrednictwem


UIImage.CreateResizableImage Method

Definition

Overloads

CreateResizableImage(UIEdgeInsets)

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

CreateResizableImage(UIEdgeInsets, UIImageResizingMode)

Creates a new image, based on the current, with the specified capInsets and resizingMode.

CreateResizableImage(UIEdgeInsets)

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

[Foundation.Export("resizableImageWithCapInsets:")]
[ObjCRuntime.ThreadSafe]
public virtual UIKit.UIImage CreateResizableImage (UIKit.UIEdgeInsets capInsets);
abstract member CreateResizableImage : UIKit.UIEdgeInsets -> UIKit.UIImage
override this.CreateResizableImage : UIKit.UIEdgeInsets -> UIKit.UIImage

Parameters

capInsets
UIEdgeInsets

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

Attributes

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 https://openradar.appspot.com/11411000 for more details. If you experience those crashes, you should try to replace this with the StretchableImage(nint, nint) 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.

Applies to

CreateResizableImage(UIEdgeInsets, UIImageResizingMode)

Creates a new image, based on the current, with the specified capInsets and resizingMode.

[Foundation.Export("resizableImageWithCapInsets:resizingMode:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.ThreadSafe]
public virtual UIKit.UIImage CreateResizableImage (UIKit.UIEdgeInsets capInsets, UIKit.UIImageResizingMode resizingMode);
abstract member CreateResizableImage : UIKit.UIEdgeInsets * UIKit.UIImageResizingMode -> UIKit.UIImage
override this.CreateResizableImage : UIKit.UIEdgeInsets * UIKit.UIImageResizingMode -> UIKit.UIImage

Parameters

capInsets
UIEdgeInsets

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

resizingMode
UIImageResizingMode

Controls whether the areas are stretched or tiled.

Returns

Attributes

Remarks

Consider the following image, the capInsets specify these borders:

The resizing mode controls whether the image is stretched or tiled

This can be used from a background thread.

Applies to