iOS Guides | Samples

UIKit.UIImage Class

Image representation in UIKit, with support for loading, saving and manipulating images.

See Also: UIImage

Syntax

[Foundation.Register("UIImage", true)]
public class UIImage : NSObject, INSSecureCoding, IUIAccessibilityIdentification, IDisposable

Remarks

Image objects do not provide direct access to the underlying image - they are immutable. The methods UIImage.AsJPEG or UIImage.AsPNG will provide the underlying image data as a JPEG or PNG.

To avoid issues with excessive memory use, UIImages objects should not be larger than 1024x1024 in size. Code-based manipulations such as resizing are not subject to this restriction.

It is possible that the system may purge UIImage objects to free up memory. If the UIImage is required later on by an application, it will be loaded again from its source file.

The following image formats are supported by the UIImage class:

  • .tiff
  • .jpg, .jpeg
  • .gif
  • .bmp
  • .ico
  • .cur
  • .xbm

Starting with iOS 8, the UIImage.FromBundle(String,NSBundle,UITraitCollection) method can be used to load a UIImage that takes into consideration a UITraitCollection. This can automatically load the proper image for the specified resolution.

Most of the members of this class can be used from a background thread, with a couple of exceptions (FromBundle methods that retrieve images from the bundle and use the built-in memory cache).

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0

The members of UIKit.UIImage are listed below.

See Also: NSObject

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Creates a UIImage by loading from the provided file name
Constructs a UIImage from the provided data, scaled by the scale factor.
Constructs an image based on the ciImage, scaled by scale and oriented per orientation.

Protected Constructors

Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

AccessibilityActivationPointCGPoint. Gets or sets the screen coordinates of the activation point for this IUIAccessibilityIdentification element.
AccessibilityElementsHiddenBoolean. Gets or sets whether accessibility elements contained in this IUIAccessibilityIdentification element are hidden.
AccessibilityFrameCGRect. Gets or sets the screen coordinates of the frame of this IUIAccessibilityIdentification element.
AccessibilityHintString. Gets or sets a localized string that describes the result of an action.
AccessibilityIdentifierString. Gets or sets an identifier that identifies this IUIAccessibilityIdentification element.
AccessibilityLabelString. Gets or sets a localized string to identify this IUIAccessibilityIdentification element.
AccessibilityLanguageString. Gets or sets the language for the UIIMage.AccessibilityLabel, UIIMage.AccessibilityValue, and UIIMage.AccessibilityHint of this IUIAccessibilityIdentification element.
AccessibilityNavigationStyleUIAccessibilityNavigationStyle. Gets or sets the navigation style.
AccessibilityPathUIBezierPath. Specifies screen coordinates for the path of an element that is used to highlight the element.
AccessibilityTraitsUIAccessibilityTrait. Gets or sets the accessibility traits that best characterize this IUIAccessibilityIdentification element.
AccessibilityValueString. Specifies a localized string that contains the value of this IUIAccessibilityIdentification element.
AccessibilityViewIsModalBoolean. Gets or sets whether VoiceOver ignores elements in sibling views of this image object.
[read-only]
AlignmentRectInsetsUIEdgeInsets. Alignment metadata that provides hints for aligning the UIImage content.
[read-only]
static
AnnouncementDidFinishNotificationNSString. Notification constant for AnnouncementDidFinish
[read-only]
static
AnnouncementNotificationInt32. Gets the notification posted by an application that an announcement requires assistive technology.
[read-only]
static
AssistiveTechnologyKeyNSString. The string "UIAccessibilityAssistiveTechnologyKey" which can be used to distinguish accessibility notifications..
[read-only]
static
AssistiveTouchStatusDidChangeNotificationNSString. Notification constant for AssistiveTouchStatusDidChange
[read-only]
static
BoldTextStatusDidChangeNotificationNSString. Notification constant for BoldTextStatusDidChange
[read-only]
CapInsetsUIEdgeInsets. The portions of a image that are not resized when the image is stretched. Read-only.
[read-only]
CGImageCGImage. The underlying image data. Read-only.
[read-only]
CIImageCIImage. The underlying CIImage data. Read-only.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
static
ClosedCaptioningStatusDidChangeNotificationNSString. Notification constant for ClosedCaptioningStatusDidChange
[read-only]
CurrentScalenfloat. The scale of the image.
[read-only]
static
DarkerSystemColorsStatusDidChangeNotificationNSString. Notification constant for DarkerSystemColorsStatusDidChange
[read-only]
DurationDouble. The time interval to display the animated image. Read-only.
[read-only]
static
ElementFocusedNotificationNSString. Notification constant for ElementFocused
[read-only]
FlipsForRightToLeftLayoutDirectionBoolean. Whether this image is mirrored when layout is right-to-left.
[read-only]
static
FocusedElementKeyNSString. A string constant used by accessibility APIs (see UIAccessibility.FocusedElement) to identify the focused element.
[read-only]
static
GrayscaleStatusDidChangeNotificationNSString. Notification constant for GrayscaleStatusDidChange
[read-only]
static
GuidedAccessStatusDidChangeNotificationNSString. Notification constant for GuidedAccessStatusDidChange
[read-only]
static
HearingDevicePairedEarDidChangeNotificationNSString. Notification constant for HearingDevicePairedEarDidChange
[read-only]
ImageAssetUIImageAsset. Gets an image asset with which the image is associated.
[read-only]
ImageRendererFormatUIGraphicsImageRendererFormat.
[read-only]
ImagesUIImage[]. An array of UIKit.UIImage objects that make up an animated iamge.
[read-only]
static
InvertColorsStatusDidChangeNotificationNSString. Notification constant for InvertColorsStatusDidChange
IsAccessibilityElementBoolean. Gets or sets whether this image is an accessibility object that an assistive app can access.
[read-only]
static
LayoutChangedNotificationInt32. Gets the notification posted by an application that the layout of a screen has changed.
[read-only]
LeftCapWidthnint. The width of the left cap.
[read-only]
static
MonoAudioStatusDidChangeNotificationNSString. Notification constant for MonoAudioStatusDidChange
[read-only]
static
NotificationSwitchControlIdentifierNSString. Notification constant for NotificationSwitchContr
[read-only]
static
NotificationVoiceOverIdentifierNSString. Notification constant for NotificationVoiceOv
[read-only]
OrientationUIImageOrientation. The orienation of the image. Read-only.
[read-only]
static
PageScrolledNotificationInt32. Gets the notification posted by an application that a scroll action has finished.
[read-only]
static
PauseAssistiveTechnologyNotificationInt32. Pauses assistive technology notifications.
[read-only]
static
ReadableTypeIdentifiersForItemProviderString[].
[read-only]
static
ReduceMotionStatusDidChangeNotificationNSString. Notification constant for ReduceMotionStatusDidChange
[read-only]
static
ReduceTransparencyStatusDidChangeNotificationNSString. Notification constant for ReduceTransparencyStatusDidChange
[read-only]
RenderingModeUIImageRenderingMode. The default value is UIRenderingMode.Automatic.
[read-only]
ResizingModeUIImageResizingMode. The resizing mode used by the image.
[read-only]
static
ResumeAssistiveTechnologyNotificationInt32. Resumes assistive technology notifications.
[read-only]
static
ScreenChangedNotificationInt32. Gets the notification posted by an application that a new view appears that includes a major portion of the screen.
[read-only]
static
ShakeToUndoDidChangeNotificationNSString. Notification constant for ShakeToUndoDidChange
ShouldGroupAccessibilityChildrenBoolean. Gets or sets whether VoiceOver groups elements that are children of this object regardless of their positions.
[read-only]
SizeCGSize. The dimensions of the image. Read-only.
[read-only]
static
SpeakScreenStatusDidChangeNotificationNSString. Notification constant for SpeakScreenStatusDidChange
[read-only]
static
SpeakSelectionStatusDidChangeNotificationNSString. Notification constant for SpeakSelectionStatusDidChange
[read-only]
static
SpeechAttributeLanguageNSString. Gets a BCP-47 language code.
[read-only]
static
SpeechAttributePitchNSString. Gets the value from 0.0 to 2.0 that determines the pitch for a spoken string.
[read-only]
static
SpeechAttributePunctuationNSString. Gets a value to be interpreted as a bool that determines whether the punctuation in a string is pronounced.
[read-only]
static
SwitchControlStatusDidChangeNotificationNSString. Notification constant for SwitchControlStatusDidChange
[read-only]
TopCapHeightnint. The height of the top cap (non-resizable area).
[read-only]
static
TraitAdjustableInt64. Gets a trait that allows continuous adjustment of an accessibility element through a range of values.
[read-only]
static
TraitAllowsDirectInteractionInt64. Gets a trait that allows direct touch interaction for users.
[read-only]
static
TraitButtonInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element should be treated as a button.
[read-only]
static
TraitCausesPageTurnInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element should turn the page when VoiceOver finishes that page.
[read-only]
TraitCollectionUITraitCollection. Returns a trait collection.
[read-only]
static
TraitHeaderInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element is a header that divides content into sections.
[read-only]
static
TraitImageInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element should be treated as an image.
[read-only]
static
TraitKeyboardKeyInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element acts like a keyboard key.
[read-only]
static
TraitLinkInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element should be considered a link.
[read-only]
static
TraitNoneInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element has no traits.
[read-only]
static
TraitNotEnabledInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element is not enabled.
[read-only]
static
TraitPlaysSoundInt64. Gets a trait that indicates that this IUIAccessibilityIdentification elements plays its own sound when activated.
[read-only]
static
TraitSearchFieldInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element should be considered a search field.
[read-only]
static
TraitSelectedInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element is selected.
[read-only]
static
TraitStartsMediaSessionInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element starts a media session when it is activated.
[read-only]
static
TraitStaticTextInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element should be treated as static text.
[read-only]
static
TraitSummaryElementInt64. Gets a trait that provides summary information when an application starts.
[read-only]
static
TraitTabBarInt64.
[read-only]
static
TraitUpdatesFrequentlyInt64. Gets a trait that indicates that this IUIAccessibilityIdentification element updates its UIIMage.AccessibilityLabel or UIIMage.AccessibilityValue.
[read-only]
static
UnfocusedElementKeyNSString. A string constant used by accessibility APIs (see UIAccessibility.FocusedElement) to identify the previously focused element.
[read-only]
static
VoiceOverStatusChangedNSString. Gets a notification that VoiceOver starts or stops.

Public Methods

AccessibilityActivate() : Boolean
Activates accessibility for this UIImage, returning true on success.
AsJPEG() : NSData
Encodes the image with minimal compression (maximum quality) into a NSData byte blob using the JPEG encoding.
AsJPEG(nfloat) : NSData
Encodes the image into a NSData byte blob using the JPEG encoding.
AsPNG() : NSData
Encodes the image into a NSData byte blob using the PNG encoding.
static
CreateAnimatedImage(String, Double) : UIImage
Creates an animated image from a series of files.
static
CreateAnimatedImage(UIImage[], Double) : UIImage
This method will create a animated image from a collection of images.
static
CreateAnimatedImage(String, UIEdgeInsets, Double) : UIImage
Creates a new animated image by loading a set of identically sized and scaled image files that have names that begin with name and that have sequential numerical suffixes.
static
CreateAnimatedImage(String, UIEdgeInsets, UIImageResizingMode, Double) : UIImage
Factory method to create an animated image with end caps and the specified resizingMode.
CreateResizableImage(UIEdgeInsets) : UIImage
Creates a new image from the current instance and applies the specified cap insets.
CreateResizableImage(UIEdgeInsets, UIImageResizingMode) : UIImage
Creates a new image, based on the current, with the specified capInsets and resizingMode.
Draw(CGPoint)
Draws the image at the specified position.
Draw(CGRect)
This method will draw the image (scaling as necessary) in the rectangle specified.
Draw(CGBlendMode, CGPoint, nfloat)
This method will draw an image starting at the specified point.
Draw(CGBlendMode, CGRect, nfloat)
This method will draw an image in the specified rectangle.
DrawAsPatternInRect(CGRect)
This method will draw an image in the specified rectangle.
EncodeTo(NSCoder)
Encodes the state of the object on the provided encoder
static
FromBundle(String) : UIImage
Loads an image relative to the application bundle, and caches its result.
static
FromBundle(String, NSBundle, UITraitCollection) : UIImage
Gets an image from the specified bundle that is compatible with the specified trait collection.
static
FromFile(String) : UIImage
Create an image object from the specified file.
static
FromImage(CGImage) : UIImage
Creates a new image oject from a Quartz image.
static
FromImage(CIImage) : UIImage
Factory method to create a UIImage from a Core Image CIImage.
static
FromImage(CGImage, UIImageOrientation, nfloat) : UIImage
Factory method to create a UIImage from a Core Graphics CGImage, with the specified scale and orientation.
static
FromImage(CIImage, UIImageOrientation, nfloat) : UIImage
Factory method to create a UIImage from a Core Image CIImage, with the specified scale and orientation.
static
FromResource(Assembly, String) : UIImage
Loads an image from a resource embedded in the assembly.
GetImageFlippedForRightToLeftLayoutDirection() : UIImage
Developers can override this method to provide an appropriate image for left-to-right layouts.
GetImageWithHorizontallyFlippedOrientation() : UIImage
ImageWithAlignmentRectInsets(UIEdgeInsets) : UIImage
Creates a UIImage based on this, with the specified alignmentInsets.
ImageWithRenderingMode(UIImageRenderingMode) : UIImage
Creates a UIImage based on the current one, with the specified renderingMode.
static
LoadFromData(NSData) : UIImage
Will create an image from data that originated from a file or was programmatically created.
static
LoadFromData(NSData, nfloat) : UIImage
Factory method to create a UIImage from the provided data, at the specified scale.
SaveToPhotosAlbum(UIImage+SaveStatus)
Saves the specified image into the Photos Album.
Scale(CGSize) : UIImage
Scales the image up or down.
Scale(CGSize, nfloat) : UIImage
Scales the image up or down.
StretchableImage(nint, nint) : UIImage
Creates a stretchable image with the specified parameters. Deprecated in iOS 5, but still useful since the replacement is known to have bugs.