iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UIKit Function Reference

Options
Deployment Target:

On This Page
Language:

UIKit Function Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

The UIKit framework defines a number of functions, many of them used in graphics and drawing operations.

Functions

  • This function is called in the main entry point to create the application object and the application delegate and set up the event cycle.

    Declaration

    Swift

    func UIApplicationMain(_ argc: Int32, _ argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>>, _ principalClassName: String!, _ delegateClassName: String!) -> Int32

    Objective-C

    int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName );

    Parameters

    argc

    The count of arguments in argv; this usually is the corresponding parameter to main.

    argv

    A variable list of arguments; this usually is the corresponding parameter to main.

    principalClassName

    The name of the UIApplication class or subclass. If you specify nil, UIApplication is assumed.

    delegateClassName

    The name of the class from which the application delegate is instantiated. If principalClassName designates a subclass of UIApplication, you may designate the subclass as the delegate; the subclass instance receives the application-delegate messages. Specify nil if you load the delegate object from your application’s main nib file.

    Return Value

    Even though an integer return type is specified, this function never returns. When users exits an iOS application by pressing the Home button, the application moves to the background.

    Discussion

    This function instantiates the application object from the principal class and instantiates the delegate (if any) from the given class and sets the delegate for the application. It also sets up the main event loop, including the application’s run loop, and begins processing events. If the application’s Info.plist file specifies a main nib file to be loaded, by including the NSMainNibFile key and a valid nib file name for the value, this function loads that nib file.

    Despite the declared return type, this function never returns. For more information on how this function behaves, see “Core App Objects” in App Programming Guide for iOS.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns the data for the specified image in JPEG format.

    Declaration

    Swift

    func UIImageJPEGRepresentation(_ image: UIImage!, _ compressionQuality: CGFloat) -> NSData!

    Objective-C

    NSData * UIImageJPEGRepresentation ( UIImage *image, CGFloat compressionQuality );

    Parameters

    image

    The original image data.

    compressionQuality

    The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality).

    Return Value

    A data object containing the JPEG data, or nil if there was a problem generating the data. This function may return nil if the image has no data or if the underlying CGImageRef contains data in an unsupported bitmap format.

    Discussion

    If the image object’s underlying image data has been purged, calling this function forces that data to be reloaded into memory.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns the data for the specified image in PNG format

    Declaration

    Swift

    func UIImagePNGRepresentation(_ image: UIImage!) -> NSData!

    Objective-C

    NSData * UIImagePNGRepresentation ( UIImage *image );

    Parameters

    image

    The original image data.

    Return Value

    A data object containing the PNG data, or nil if there was a problem generating the data. This function may return nil if the image has no data or if the underlying CGImageRef contains data in an unsupported bitmap format.

    Discussion

    If the image object’s underlying image data has been purged, calling this function forces that data to be reloaded into memory.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Adds the specified image to the user’s Camera Roll album.

    Declaration

    Swift

    func UIImageWriteToSavedPhotosAlbum(_ image: UIImage!, _ completionTarget: AnyObject!, _ completionSelector: Selector, _ contextInfo: UnsafeMutablePointer<Void>)

    Objective-C

    void UIImageWriteToSavedPhotosAlbum ( UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo );

    Parameters

    image

    The image to write to the Camera Roll album.

    completionTarget

    Optionally, the object whose selector should be called after the image has been written to the Camera Roll album.

    completionSelector

    The method selector, of the completionTarget object, to call. This optional method should conform to the following signature:

    • - (void) image: (UIImage *) image
    • didFinishSavingWithError: (NSError *) error
    • contextInfo: (void *) contextInfo;
    contextInfo

    An optional pointer to any context-specific data that you want passed to the completion selector.

    Discussion

    When used with an image picker controller, you would typically call this function within your imagePickerController:didFinishPickingMediaWithInfo: delegate method implementation.

    The use of the completionTarget, completionSelector, and contextInfo parameters is optional and necessary only if you want to be notified asynchronously when the function finishes writing the image to the user’s Camera Roll or Saved Photos album. If you do not want to be notified, pass nil for these parameters.

    When used on an iOS device without a camera, this method adds the image to the Saved Photos album rather than to the Camera Roll album.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Adds the movie at the specified path to the user’s Camera Roll album.

    Declaration

    Swift

    func UISaveVideoAtPathToSavedPhotosAlbum(_ videoPath: String!, _ completionTarget: AnyObject!, _ completionSelector: Selector, _ contextInfo: UnsafeMutablePointer<Void>)

    Objective-C

    void UISaveVideoAtPathToSavedPhotosAlbum ( NSString *videoPath, id completionTarget, SEL completionSelector, void *contextInfo );

    Parameters

    videoPath

    The filesystem path to the movie file you want to save to the Camera Roll album.

    completionTarget

    Optionally, the object whose selector should be called after the movie has been written to the Camera Roll album.

    completionSelector

    The method selector, of the completionTarget object, to call. This optional method should conform to the following signature:

    • - (void) video: (NSString *) videoPath
    • didFinishSavingWithError: (NSError *) error
    • contextInfo: (void *) contextInfo;
    contextInfo

    An optional pointer to any context-specific data that you want passed to the completion selector.

    Discussion

    When used with an image picker controller, you would typically call this function within your imagePickerController:didFinishPickingMediaWithInfo: delegate method implementation.

    Before calling this function, call the UIVideoAtPathIsCompatibleWithSavedPhotosAlbum function to determine if it is possible to save movies to the Camera Roll album. For a code example, refer to Camera Programming Topics for iOS.

    The use of the completionTarget, completionSelector, and contextInfo parameters is optional and necessary only if you want to be notified asynchronously when the function finishes writing the movie to the user’s Camera Roll or Saved Photos album. If you do not want to be notified, pass nil for these parameters.

    When used on an iOS device without a camera, this method adds the movie to the Saved Photos album rather than to the Camera Roll album.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.1 and later.

  • Returns a Boolean value indicating whether the specified video can be saved to user’s Camera Roll album.

    Declaration

    Swift

    func UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(_ videoPath: String!) -> Bool

    Objective-C

    BOOL UIVideoAtPathIsCompatibleWithSavedPhotosAlbum ( NSString *videoPath );

    Parameters

    videoPath

    The filesystem path to the movie file you want to save.

    Return Value

    YEStrue if the video can be saved to the Camera Roll album or NOfalse if it cannot.

    Discussion

    Not all devices are able to play video files placed in the user’s Camera Roll album. Before attempting to save a video, call this function and check its return value to ensure that saving the video is supported for the current device. For a code example, refer to Camera Programming Topics for iOS.

    When used on an iOS device without a camera, this method indicates whether the specified movie can be saved to the Saved Photos album rather than to the Camera Roll album.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.1 and later.

  • Returns the current graphics context.

    Declaration

    Swift

    func UIGraphicsGetCurrentContext() -> CGContext!

    Objective-C

    CGContextRef UIGraphicsGetCurrentContext ( void );

    Return Value

    The current graphics context.

    Discussion

    The current graphics context is nil by default. Prior to calling its drawRect: method, view objects push a valid context onto the stack, making it current. If you are not using a UIView object to do your drawing, however, you must push a valid context onto the stack manually using the UIGraphicsPushContext function.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Makes the specified graphics context the current context.

    Declaration

    Swift

    func UIGraphicsPushContext(_ context: CGContext!)

    Objective-C

    void UIGraphicsPushContext ( CGContextRef context );

    Parameters

    context

    The graphics context to make the current context.

    Discussion

    You can use this function to save the previous graphics state and make the specified context the current context. You must balance calls to this function with matching calls to the UIGraphicsPopContext function.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Removes the current graphics context from the top of the stack, restoring the previous context.

    Declaration

    Swift

    func UIGraphicsPopContext()

    Objective-C

    void UIGraphicsPopContext ( void );

    Discussion

    Use this function to balance calls to the UIGraphicsPushContext function.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Creates a bitmap-based graphics context and makes it the current context.

    Declaration

    Swift

    func UIGraphicsBeginImageContext(_ size: CGSize)

    Objective-C

    void UIGraphicsBeginImageContext ( CGSize size );

    Parameters

    size

    The size of the new bitmap context. This represents the size of the image returned by the UIGraphicsGetImageFromCurrentImageContext function.

    Discussion

    This function is equivalent to calling the UIGraphicsBeginImageContextWithOptions function with the opaque parameter set to NOfalse and a scale factor of 1.0.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Creates a bitmap-based graphics context with the specified options.

    Declaration

    Swift

    func UIGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat)

    Objective-C

    void UIGraphicsBeginImageContextWithOptions ( CGSize size, BOOL opaque, CGFloat scale );

    Parameters

    size

    The size (measured in points) of the new bitmap context. This represents the size of the image returned by the UIGraphicsGetImageFromCurrentImageContext function. To get the size of the bitmap in pixels, you must multiply the width and height values by the value in the scale parameter.

    opaque

    A Boolean flag indicating whether the bitmap is opaque. If you know the bitmap is fully opaque, specify YEStrue to ignore the alpha channel and optimize the bitmap’s storage. Specifying NOfalse means that the bitmap must include an alpha channel to handle any partially transparent pixels.

    scale

    The scale factor to apply to the bitmap. If you specify a value of 0.0, the scale factor is set to the scale factor of the device’s main screen.

    Discussion

    You use this function to configure the drawing environment for rendering into a bitmap. The format for the bitmap is a ARGB 32-bit integer pixel format using host-byte order. If the opaque parameter is YEStrue, the alpha channel is ignored and the bitmap is treated as fully opaque (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host). Otherwise, each pixel uses a premultipled ARGB format (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host).

    The environment also uses the default coordinate system for UIKit views, where the origin is in the upper-left corner and the positive axes extend down and to the right of the origin. The supplied scale factor is also applied to the coordinate system and resulting images. The drawing environment is pushed onto the graphics context stack immediately.

    While the context created by this function is the current context, you can call the UIGraphicsGetImageFromCurrentImageContext function to retrieve an image object based on the current contents of the context. When you are done modifying the context, you must call the UIGraphicsEndImageContext function to clean up the bitmap drawing environment and remove the graphics context from the top of the context stack. You should not use the UIGraphicsPopContext function to remove this type of context from the stack.

    In most other respects, the graphics context created by this function behaves like any other graphics context. You can change the context by pushing and popping other graphics contexts. You can also get the bitmap context using the UIGraphicsGetCurrentContext function.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.0 and later.

  • Returns an image based on the contents of the current bitmap-based graphics context.

    Declaration

    Swift

    func UIGraphicsGetImageFromCurrentImageContext() -> UIImage!

    Objective-C

    UIImage * UIGraphicsGetImageFromCurrentImageContext ( void );

    Return Value

    A image object containing the contents of the current bitmap graphics context.

    Discussion

    You should call this function only when a bitmap-based graphics context is the current graphics context. If the current context is nil or was not created by a call to UIGraphicsBeginImageContext, this function returns nil.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Removes the current bitmap-based graphics context from the top of the stack.

    Declaration

    Swift

    func UIGraphicsEndImageContext()

    Objective-C

    void UIGraphicsEndImageContext ( void );

    Discussion

    You use this function to clean up the drawing environment put in place by the UIGraphicsBeginImageContext function and to remove the corresponding bitmap-based graphics context from the top of the stack. If the current context was not created using the UIGraphicsBeginImageContext function, this function does nothing.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Modifies the current clipping path by intersecting it with the specified rectangle.

    Declaration

    Swift

    func UIRectClip(_ rect: CGRect)

    Objective-C

    void UIRectClip ( CGRect rect );

    Parameters

    rect

    The rectangle to intersect with the clipping region. If the width or height of the rectangle are less than 0, this function does not change the clipping path.

    Discussion

    Each call to this function permanently shrinks the clipping path of the current graphics context using the specified rectangle. You cannot use this function to expand the clipping region path. If the current graphics context is nil, this function does nothing.

    If you need to return the clipping path to its original shape in your drawing code, you should save the current graphics context before calling this function. To save the current state of the graphics context, call the CGContextSaveGState function before making your modifications. When you are ready to restore the original clipping region, you can then use the CGContextRestoreGState function to restore the previous graphics state.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Fills the specified rectangle with the current color.

    Declaration

    Swift

    func UIRectFill(_ rect: CGRect)

    Objective-C

    void UIRectFill ( CGRect rect );

    Parameters

    rect

    The rectangle defining the area in which to draw.

    Discussion

    Fills the specified rectangle using the fill color of the current graphics context and the kCGBlendModeCopy blend mode.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Fills a rectangle with the current fill color using the specified blend mode.

    Declaration

    Swift

    func UIRectFillUsingBlendMode(_ rect: CGRect, _ blendMode: CGBlendMode)

    Objective-C

    void UIRectFillUsingBlendMode ( CGRect rect, CGBlendMode blendMode );

    Parameters

    rect

    The rectangle defining the area in which to draw.

    blendMode

    The blend mode to use during drawing.

    Discussion

    This function draws the rectangle in the current graphics context. If the current graphics context is nil, this function does nothing.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Draws a frame around the inside of the specified rectangle.

    Declaration

    Swift

    func UIRectFrame(_ rect: CGRect)

    Objective-C

    void UIRectFrame ( CGRect rect );

    Parameters

    rect

    The rectangle defining the area in which to draw.

    Discussion

    This function draws a frame around the inside of rect in the stroke color of the current graphics context and using the kCGBlendModeCopy blend mode. The width is equal to 1.0 in the current coordinate system. Because the frame is drawn inside the rectangle, it is visible even if drawing is clipped to the rectangle. If the current graphics context is nil, this function does nothing.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Draws a frame around the inside of a rectangle using the specified blend mode.

    Declaration

    Swift

    func UIRectFrameUsingBlendMode(_ rect: CGRect, _ blendMode: CGBlendMode)

    Objective-C

    void UIRectFrameUsingBlendMode ( CGRect rect, CGBlendMode blendMode );

    Parameters

    rect

    The rectangle defining the area in which to draw.

    blendMode

    The blend mode to use during drawing.

    Discussion

    This function draws a frame around the inside of rect in the fill color of the current graphics context and using the specified blend mode. The width is equal to 1.0 in the current coordinate system. Since the frame is drawn inside the rectangle, it is visible even if drawing is clipped to the rectangle. If the current graphics context is nil, this function does nothing.

    Because this function does not draw directly on the line, but rather inside it, it uses the current fill color (not stroke color) when drawing.

    This function may be called from any thread of your app.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Creates a dictionary wherein the keys are string representations of the corresponding values’ variable names.

    Declaration

    Objective-C

    #define NSDictionaryOfVariableBindings(...) _NSDictionaryOfVariableBindings(@"" # __VA_ARGS__, __VA_ARGS__, nil)

    Discussion

    This macro is particularly useful when creating Autolayout constraints—see Auto Layout Guide. For example, the following code:

    • NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(button1, button2);

    creates the dictionary { @"button1" = button1, @"button2 = button2 }.

    Import Statement

    Objective-C

    @import UIKit;

    Availability

    Available in iOS 6.0 and later.

  • Creates a PDF-based graphics context that targets the specified mutable data object.

    Declaration

    Swift

    func UIGraphicsBeginPDFContextToData(_ data: NSMutableData!, _ bounds: CGRect, _ documentInfo: [NSObject : AnyObject]!)

    Objective-C

    void UIGraphicsBeginPDFContextToData ( NSMutableData *data, CGRect bounds, NSDictionary *documentInfo );

    Parameters

    data

    The data object to receive the PDF output data.

    bounds

    A rectangle that specifies the default size and location of PDF pages. (This value is used as the default media box for each new page.) The origin of the rectangle should typically be (0, 0). Specifying an empty rectangle (CGRectZero) sets the default page size to 8.5 by 11 inches (612 by 792 points).

    documentInfo

    A dictionary that specifies additional information to be associated with the PDF file. You can use these keys to specify additional metadata and security information for the PDF, such as the author of the PDF or the password for accessing it. The keys in this dictionary are the same keys you pass to the CGPDFContextCreate function and are described in the Auxiliary Dictionary Keys section of CGPDFContext Reference. The dictionary is retained by the new context, so on return you may safely release it.

    Specify nil if you do not want to associate any additional information with the PDF document.

    Discussion

    After creating the graphics context, this function makes it the current drawing context. Any subsequent drawing commands are therefore captured and turned into PDF data. When you are done drawing, you must call the UIGraphicsEndPDFContext function to close the PDF graphics context.

    You can use all of the same drawing routines that you would normally use to draw the contents of your application. The graphics context converts all drawing commands into PDF drawing commands automatically. However, before you issue any drawing commands to a PDF context, you must start a new page by calling the UIGraphicsBeginPDFPage or UIGraphicsBeginPDFPageWithInfo function. You can also use these functions to define additional pages later.

    After creating it, you can get the PDF context using the UIGraphicsGetCurrentContext function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Creates a PDF-based graphics context that targets a file at the specified path.

    Declaration

    Swift

    func UIGraphicsBeginPDFContextToFile(_ path: String!, _ bounds: CGRect, _ documentInfo: [NSObject : AnyObject]!) -> Bool

    Objective-C

    BOOL UIGraphicsBeginPDFContextToFile ( NSString *path, CGRect bounds, NSDictionary *documentInfo );

    Parameters

    path

    A POSIX-style path string identifying the location of the resulting PDF file. The specified path may be relative or a full path name. If a file does not exist at the specified path, one is created; otherwise, the contents of any existing file are deleted. The directories in the path must exist.

    bounds

    A rectangle that specifies the default size and location of PDF pages. (This value is used as the default media box for each new page.) The origin of the rectangle should typically be (0, 0). Specifying an empty rectangle (CGRectZero) sets the default page size to 8.5 by 11 inches (612 by 792 points).

    documentInfo

    A dictionary that specifies additional information to be associated with the PDF file. You can use these keys to specify additional metadata and security information for the PDF, such as the author of the PDF or the password for accessing it. The keys in this dictionary are the same keys you pass to the CGPDFContextCreate function and are described in the Auxiliary Dictionary Keys section of CGPDFContext Reference. The dictionary is retained by the new context, so on return you may safely release it.

    Specify nil if you do not want to associate any additional information with the PDF document.

    Return Value

    YEStrue if the PDF context was created successfully or NOfalse if it was not.

    Discussion

    After creating the graphics context, this function makes it the current drawing context. Any subsequent drawing commands are therefore captured and turned into PDF data. When you are done drawing, you must call the UIGraphicsEndPDFContext function to close the PDF graphics context.

    You can use all of the same drawing routines that you would normally use to draw the contents of your application. However, before you issue any drawing commands to a PDF context, you must start a new page by calling the UIGraphicsBeginPDFPage or UIGraphicsBeginPDFPageWithInfo function. You can also use these functions to define additional pages later.

    After creating it, you can get the PDF context using the UIGraphicsGetCurrentContext function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Closes a PDF graphics context and pops it from the current context stack.

    Declaration

    Swift

    func UIGraphicsEndPDFContext()

    Objective-C

    void UIGraphicsEndPDFContext ( void );

    Discussion

    You must call this function after you finish drawing to a PDF graphics context. This function closes the current open page and removes the PDF context from the graphics context stack. It also releases the CGContextRef associated with the PDF context. If the current graphics context is not a PDF context, this function does nothing.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Marks the beginning of a new page in a PDF context and configures it using default values.

    Declaration

    Swift

    func UIGraphicsBeginPDFPage()

    Objective-C

    void UIGraphicsBeginPDFPage ( void );

    Discussion

    This function ends any previous page before beginning a new one. It sets the media box of the new page to the rectangle you specified when you created the PDF context.

    If the current graphics context is not a PDF context, this function does nothing.

    You must call this function or the UIGraphicsBeginPDFPageWithInfo function before you issue any drawing commands.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Marks the beginning of a new page in a PDF context and configures it using the specified values.

    Declaration

    Swift

    func UIGraphicsBeginPDFPageWithInfo(_ bounds: CGRect, _ pageInfo: [NSObject : AnyObject]!)

    Objective-C

    void UIGraphicsBeginPDFPageWithInfo ( CGRect bounds, NSDictionary *pageInfo );

    Parameters

    bounds

    A rectangle that specifies the size and location of the new PDF page. This rectangle corresponds to the media box rectangle for the page.

    pageInfo

    A dictionary that specifies additional page-related information, such as the boxes that define different parts of the page. For a list of keys you can include in this dictionary, see Box Dictionary Keys in CGPDFContext Reference. The dictionary is retained by the new page, so you may release it after this function returns.

    Specify nil if you do not want to associate any additional information with the page.

    Discussion

    This function ends any previous page before beginning a new one. It sets the media box of the new page to the value in the kCGPDFContextMediaBox key of the pageInfo dictionary, or to the value in the bounds parameter if the dictionary does not contain the key.

    If the current graphics context is not a PDF context, this function does nothing.

    You must call this function or the UIGraphicsBeginPDFPageWithInfo function before you issue any drawing commands.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Returns the current page bounds.

    Declaration

    Swift

    func UIGraphicsGetPDFContextBounds() -> CGRect

    Objective-C

    CGRect UIGraphicsGetPDFContextBounds ( void );

    Return Value

    The current page bounds associated with the PDF context or CGRectZero if the current context is not a PDF context.

    Discussion

    If a page has not yet been started, this function returns the default media box you specified when you created the PDF context; otherwise, it returns the page bounds for the current page.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Creates a jump destination in the current page.

    Declaration

    Swift

    func UIGraphicsAddPDFContextDestinationAtPoint(_ name: String!, _ point: CGPoint)

    Objective-C

    void UIGraphicsAddPDFContextDestinationAtPoint ( NSString *name, CGPoint point );

    Parameters

    name

    The name of the destination point. The name you assign is local to the PDF document and is what you use when creating links to this destination.

    point

    A point on the current page of the PDF context.

    Discussion

    This function marks the specified point in the current page as the destination of a jump. When the user taps a link that takes them to this jump destination, the PDF document scrolls until the specified point is visible.

    If the current graphics context is not a PDF context, this function does nothing.

    For information on how to create links to this destination, see the UIGraphicsSetPDFContextDestinationForRect function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Links a rectangle on the current page to the specified jump destination.

    Declaration

    Swift

    func UIGraphicsSetPDFContextDestinationForRect(_ name: String!, _ rect: CGRect)

    Objective-C

    void UIGraphicsSetPDFContextDestinationForRect ( NSString *name, CGRect rect );

    Parameters

    name

    A named destination in the PDF document. This is the same name you used when creating the jump destination using the UIGraphicsAddPDFContextDestinationAtPoint function.

    rect

    A rectangle on the current page of the PDF context.

    Discussion

    You use this function to create live links within a PDF document. Tapping the specified rectangle in the PDF document causes the document to display the contents at the associated jump destination.

    If the current graphics context is not a PDF context, this function does nothing.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Links a rectangle on the current page to the specified URL.

    Declaration

    Swift

    func UIGraphicsSetPDFContextURLForRect(_ url: NSURL!, _ rect: CGRect)

    Objective-C

    void UIGraphicsSetPDFContextURLForRect ( NSURL *url, CGRect rect );

    Parameters

    url

    The URL to open.

    rect

    A rectangle on the current page of the PDF context.

    Discussion

    You use this function to create external links within a PDF document. If the URL you specify is a type handled by a different application, tapping the rectangle opens that application.

    If the current graphics context is not a PDF context, this function does nothing.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Returns a Core Graphics affine transform structure corresponding to the data in a given string.

    Declaration

    Swift

    func CGAffineTransformFromString(_ string: String!) -> CGAffineTransform

    Objective-C

    CGAffineTransform CGAffineTransformFromString ( NSString *string );

    Parameters

    string

    A string whose contents are of the form “{a, b, c, d, tx, ty}”, where a, b, c, d, tx, and ty are the floating-point component values of the CGAffineTransform data structure. An example of a valid string is @”{1,0,0,1,2.5,3.0}”. The string is not localized, so items are always separated with a comma. For information about the position of each value in the transform array, see CGAffineTransform Reference.

    Return Value

    A Core Graphics affine transform structure. If the string is not well-formed, the function returns the identity transform.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromCGAffineTransform function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a Core Graphics point structure corresponding to the data in a given string.

    Declaration

    Swift

    func CGPointFromString(_ string: String!) -> CGPoint

    Objective-C

    CGPoint CGPointFromString ( NSString *string );

    Parameters

    string

    A string whose contents are of the form “{x,y}”, where x is the x coordinate and y is the y coordinate. The x and y values can represent integer or float values. An example of a valid string is @”{3.0,2.5}”. The string is not localized, so items are always separated with a comma.

    Return Value

    A Core Graphics structure that represents a point. If the string is not well-formed, the function returns CGPointZero.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromCGPoint function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a Core Graphics rectangle structure corresponding to the data in a given string.

    Declaration

    Swift

    func CGRectFromString(_ string: String!) -> CGRect

    Objective-C

    CGRect CGRectFromString ( NSString *string );

    Parameters

    string

    A string whose contents are of the form “{{x,y},{w, h}}”, where x is the x coordinate, y is the y coordinate, w is the width, and h is the height. These components can represent integer or float values. An example of a valid string is @”{{3,2},{4,5}}”. The string is not localized, so items are always separated with a comma.

    Return Value

    A Core Graphics structure that represents a rectangle. If the string is not well-formed, the function returns CGRectZero.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromCGRect function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a Core Graphics size structure corresponding to the data in a given string.

    Declaration

    Swift

    func CGSizeFromString(_ string: String!) -> CGSize

    Objective-C

    CGSize CGSizeFromString ( NSString *string );

    Parameters

    string

    A string whose contents are of the form “{w, h}”, where w is the width and h is the height. The w and h values can be integer or float values. An example of a valid string is @”{3.0,2.5}”. The string is not localized, so items are always separated with a comma.

    Return Value

    A Core Graphics structure that represents a size. If the string is not well-formed, the function returns CGSizeZero.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromCGSize function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a Core Graphics vector corresponding to the data in a given string.

    Declaration

    Swift

    func CGVectorFromString(_ string: String!) -> CGVector

    Objective-C

    CGVector CGVectorFromString ( NSString *string );

    Parameters

    string

    A string whose contents are of the form “{dx, dy}”, where dx is the x-coordinate of the vector and dy is the y-coordinate. The dx and dy values can be integer or float values. An example of a valid string is @”{3.0,2.5}”. The string is not localized, so items are always separated with a comma.

    Return Value

    A Core Graphics structure that represents a two-dimensional vector. If the string is not well-formed, the function returns a vector whose dx and dy values are 0.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromCGVector function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a string formatted to contain the data from an affine transform.

    Declaration

    Swift

    func NSStringFromCGAffineTransform(_ transform: CGAffineTransform) -> String!

    Objective-C

    NSString * NSStringFromCGAffineTransform ( CGAffineTransform transform );

    Parameters

    transform

    A Core Graphics affine transform structure.

    Return Value

    A string that corresponds to transform. See CGAffineTransformFromString for a discussion of the string format.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a string formatted to contain the data from a point.

    Declaration

    Swift

    func NSStringFromCGPoint(_ point: CGPoint) -> String!

    Objective-C

    NSString * NSStringFromCGPoint ( CGPoint point );

    Parameters

    point

    A Core Graphics structure representing a point.

    Return Value

    A string that corresponds to point. See CGPointFromString for a discussion of the string format.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a string formatted to contain the data from a rectangle.

    Declaration

    Swift

    func NSStringFromCGRect(_ rect: CGRect) -> String!

    Objective-C

    NSString * NSStringFromCGRect ( CGRect rect );

    Parameters

    rect

    A Core Graphics structure representing a rectangle.

    Return Value

    A string that corresponds to rect. See CGRectFromString for a discussion of the string format.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    CGRectFromString

  • Returns a string formatted to contain the data from a size data structure.

    Declaration

    Swift

    func NSStringFromCGSize(_ size: CGSize) -> String!

    Objective-C

    NSString * NSStringFromCGSize ( CGSize size );

    Parameters

    size

    A Core Graphics structure representing a size.

    Return Value

    A string that corresponds to size. See CGSizeFromString for a discussion of the string format.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    CGSizeFromString

  • Returns a string formatted to contain the data from a vector data structure.

    Declaration

    Swift

    func NSStringFromCGVector(_ vector: CGVector) -> String!

    Objective-C

    NSString * NSStringFromCGVector ( CGVector vector );

    Parameters

    vector

    A Core Graphics structure representing a two-dimensional vector.

    Return Value

    A string that corresponds to vector. See CGVectorFromString for a discussion of the string format.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a string formatted to contain the data from an edge insets structure.

    Declaration

    Swift

    func NSStringFromUIEdgeInsets(_ insets: UIEdgeInsets) -> String!

    Objective-C

    NSString * NSStringFromUIEdgeInsets ( UIEdgeInsets insets );

    Parameters

    insets

    A UIKit edge insets data structure.

    Return Value

    A string that corresponds to insets. See UIEdgeInsetsFromString for a discussion of the string format.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a string formatted to contain the data from an offset structure.

    Declaration

    Swift

    func NSStringFromUIOffset(_ offset: UIOffset) -> String!

    Objective-C

    NSString * NSStringFromUIOffset ( UIOffset offset );

    Parameters

    offset

    A UIKit offset data structure.

    Return Value

    A string that corresponds to offset.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a UIKit edge insets structure corresponding to the data in a given string.

    Declaration

    Swift

    func UIEdgeInsetsFromString(_ string: String!) -> UIEdgeInsets

    Objective-C

    UIEdgeInsets UIEdgeInsetsFromString ( NSString *string );

    Parameters

    string

    A string whose contents are of the form “{top, left, bottom, right}”, where top, left, bottom, right are the floating-point component values of the UIEdgeInsets structure. An example of a valid string is @”{3.0,8.0,3.0,5.0}”. The string is not localized, so items are always separated with a comma.

    Return Value

    An edge insets data structure. If the string is not well-formed, the function returns UIEdgeInsetsZero.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromUIEdgeInsets function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Returns a UIKit offset structure corresponding to the data in a given string.

    Declaration

    Swift

    func UIOffsetFromString(_ string: String!) -> UIOffset

    Objective-C

    UIOffset UIOffsetFromString ( NSString *string );

    Parameters

    string

    A string containing a representation of an offset.

    Return Value

    An edge insets data structure. If the string is not well-formed, the function returns UIOffsetZero.

    Discussion

    In general, you should use this function only to convert strings that were previously created using the NSStringFromUIOffset function.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Creates an edge inset for a button or view.

    Declaration

    Swift

    func UIEdgeInsetsMake(_ top: CGFloat, _ left: CGFloat, _ bottom: CGFloat, _ right: CGFloat) -> UIEdgeInsets

    Objective-C

    UIEdgeInsets UIEdgeInsetsMake ( CGFloat top, CGFloat left, CGFloat bottom, CGFloat right );

    Parameters

    top

    The inset at the top of an object.

    left

    The inset on the left of an object

    bottom

    The inset on the bottom of an object.

    right

    The inset on the right of an object.

    Return Value

    An inset for a button or view

    Discussion

    An inset is a margin around the drawing rectangle where each side (left, right, top, and bottom) can have a different value.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Compares two edge insets to determine if they are the same.

    Declaration

    Swift

    func UIEdgeInsetsEqualToEdgeInsets(_ insets1: UIEdgeInsets, _ insets2: UIEdgeInsets) -> Bool

    Objective-C

    BOOL UIEdgeInsetsEqualToEdgeInsets ( UIEdgeInsets insets1, UIEdgeInsets insets2 );

    Parameters

    insets1

    An edge inset to compare with insets2.

    insets2

    An edge inset to compare with insets1.

    Return Value

    YEStrue if the edge insets are the same; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    UIEdgeInsetsMake

  • Adjusts a rectangle by the given edge insets.

    Declaration

    Swift

    func UIEdgeInsetsInsetRect(_ rect: CGRect, _ insets: UIEdgeInsets) -> CGRect

    Objective-C

    CGRect UIEdgeInsetsInsetRect ( CGRect rect, UIEdgeInsets insets );

    Parameters

    rect

    The rectangle to be adjusted.

    insets

    The edge insets to be applied to the adjustment.

    Return Value

    A rectangle that is adjusted by the UIEdgeInsets structure passed in insets.

    Discussion

    This inline function increments the origin of rect and decrements the size of rect by applying the appropriate member values of the UIEdgeInsets structure.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

    See Also

    UIEdgeInsetsMake

  • Returns an offset structure from the given components.

    Declaration

    Swift

    func UIOffsetMake(_ horizontal: CGFloat, _ vertical: CGFloat) -> UIOffset

    Objective-C

    UIOffset UIOffsetMake ( CGFloat horizontal, CGFloat vertical );

    Parameters

    horizontal

    The horizontal offset.

    vertical

    The vertical offset.

    Return Value

    An offset structure with offsets horizontal and vertical.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that indicates whether two offsets are equal.

    Declaration

    Swift

    func UIOffsetEqualToOffset(_ offset1: UIOffset, _ offset2: UIOffset) -> Bool

    Objective-C

    BOOL UIOffsetEqualToOffset ( UIOffset offset1, UIOffset offset2 );

    Parameters

    offset1

    The offset to compare with offset2.

    offset2

    The offset to compare with offset1.

    Return Value

    YEStrue if offset1 and offset2 are equal, otherwise NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value indicating whether the user interface is currently presented in a portrait orientation.

    Declaration

    Objective-C

    BOOL UIInterfaceOrientationIsPortrait ( UIInterfaceOrientation orientation );

    Parameters

    orientation

    Specify the orientation constant to check.

    Return Value

    Returns YEStrue if the interface orientation is portrait, otherwise returns NOfalse.

    Discussion

    The interface orientation can be different than the device orientation. You typically call this function in your view controller code to check the current orientation.

    Import Statement

    Objective-C

    @import UIKit;

    Availability

    Available in iOS 8.3 and later.

  • Returns a Boolean value indicating whether the user interface is currently presented in a landscape orientation.

    Declaration

    Objective-C

    BOOL UIInterfaceOrientationIsLandscape ( UIInterfaceOrientation orientation );

    Parameters

    orientation

    Specify the orientation constant to check.

    Return Value

    Returns YEStrue if the interface orientation is landscape, otherwise returns NOfalse.

    Discussion

    The interface orientation can be different than the device orientation. You typically call this function in your view controller code to check the current orientation.

    Import Statement

    Objective-C

    @import UIKit;

    Availability

    Available in iOS 8.3 and later.

  • Returns a Boolean value indicating whether the device is in a portrait orientation.

    Declaration

    Objective-C

    BOOL UIDeviceOrientationIsPortrait ( UIDeviceOrientation orientation );

    Parameters

    orientation

    Specify the value of the orientation property of the UIDevice class.

    Return Value

    Returns YEStrue if the device orientation is portrait, otherwise returns NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Availability

    Available in iOS 8.3 and later.

  • Returns a Boolean value indicating whether the device is in a landscape orientation.

    Declaration

    Objective-C

    BOOL UIDeviceOrientationIsLandscape ( UIDeviceOrientation orientation );

    Parameters

    orientation

    Specify the value of the orientation property of the UIDevice class.

    Return Value

    Returns YEStrue if the device orientation is landscape, otherwise returns NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Availability

    Available in iOS 8.3 and later.

  • Posts a notification to assistive applications.

    Declaration

    Swift

    func UIAccessibilityPostNotification(_ notification: UIAccessibilityNotifications, _ argument: AnyObject!)

    Objective-C

    void UIAccessibilityPostNotification ( UIAccessibilityNotifications notification, id argument );

    Parameters

    notification

    The notification to post (see “Notifications” in UIAccessibility Protocol Reference for a list of notifications).

    argument

    The argument specified by the notification. Pass nil unless a notification specifies otherwise.

    Discussion

    Your application might need to post accessibility notifications if you have user interface components that change very frequently or that appear and disappear.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.0 and later.

  • Converts the specified rectangle from view coordinates to screen coordinates.

    Declaration

    Swift

    func UIAccessibilityConvertFrameToScreenCoordinates(_ rect: CGRect, _ view: UIView!) -> CGRect

    Objective-C

    CGRect UIAccessibilityConvertFrameToScreenCoordinates ( CGRect rect, UIView *view );

    Parameters

    rect

    A rectangle specified in the coordinate system of the specified view.

    view

    The view that contains the specified rectangle. This parameter must not be nil.

    Return Value

    The rectangle in screen coordinates.

    Discussion

    Use this function to convert accessibility frame rectangles to screen coordinates.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Converts the specified path object to screen coordinates and returns a new path object with the results.

    Declaration

    Swift

    func UIAccessibilityConvertPathToScreenCoordinates(_ path: UIBezierPath!, _ view: UIView!) -> UIBezierPath!

    Objective-C

    UIBezierPath * UIAccessibilityConvertPathToScreenCoordinates ( UIBezierPath *path, UIView *view );

    Parameters

    path

    The path object that you want to convert. The coordinate values used to create this path object should be relative to the coordinate system of the specified view. This parameter must not be nil.

    view

    The view whose coordinate system was used to define the path. This parameter must not be nil.

    Return Value

    A new path object that has the same shape as path but whose points are specified in screen coordinates.

    Discussion

    This function adjusts the points of the path you provide to values that the accessibility system can use. You can use it to convert path objects in use by your app’s user interface before handing them to the accessibility system.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Warns users that application-specific gestures conflict with the system-defined Zoom accessibility gestures.

    Declaration

    Swift

    func UIAccessibilityRegisterGestureConflictWithZoom()

    Objective-C

    void UIAccessibilityRegisterGestureConflictWithZoom ( void );

    Discussion

    Use this function if your application uses multi-finger gestures that conflict with the gestures used by system Zoom (that is, three-finger gestures). When this is the case, the user is presented with the choice of turning off Zoom or continuing.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Transitions the app to or from Single App mode asynchronously.

    Declaration

    Swift

    func UIAccessibilityRequestGuidedAccessSession(_ enable: Bool, _ completionHandler: ((Bool) -> Void)!)

    Objective-C

    void UIAccessibilityRequestGuidedAccessSession ( BOOL enable, void (^completionHandler)(BOOL didSucceed) );

    Parameters

    enable

    Specify YEStrue to put the device into Single App mode for this app or NOfalse to exit Single App mode.

    completionHandler

    The block that notifies your app of the success or failure of the operation. This block takes the following parameter:

    didSucceed

    If YEStrue, the app transitioned to or from Single App mode successfully. If NOfalse, the app or device is not eligible for Single App mode or there was some other error.

    Discussion

    You can use this method to lock your app into Single App mode and to release it from that mode later. For example, a test-taking app might enter this mode at the beginning of a test and exit it when the user completes the test. Entering Single App mode is supported only for devices that are supervised using Mobile Device Management (MDM), and the app itself must be enabled for this mode by MDM. You must balance each call to enter Single App mode with a call to exit that mode.

    Because entering or exiting Single App mode might take some time, this method executes asynchronously and notifies you of the results using the completionHandler block.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Notifies the system that the app’s focus has changed to a new location.

    Declaration

    Swift

    func UIAccessibilityZoomFocusChanged(_ type: UIAccessibilityZoomType, _ frame: CGRect, _ view: UIView!)

    Objective-C

    void UIAccessibilityZoomFocusChanged ( UIAccessibilityZoomType type, CGRect frame, UIView *view );

    Parameters

    type

    A Introduction constant that identifies the type of Zoom.

    frame

    The frame that is currently zoomed, in screen coordinates.

    view

    The view that contains the zoomed frame.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value indicating whether bold text is enabled.

    Declaration

    Swift

    func UIAccessibilityIsBoldTextEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsBoldTextEnabled ( void );

    Return Value

    YEStrue if the user has enabled Bold Text in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether closed captioning is enabled.

    Declaration

    Swift

    func UIAccessibilityIsClosedCaptioningEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsClosedCaptioningEnabled ( void );

    Return Value

    YEStrue if the user has enabled closed captioning in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value indicating whether darken colors is enabled.

    Declaration

    Swift

    func UIAccessibilityDarkerSystemColorsEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityDarkerSystemColorsEnabled ( void );

    Return Value

    YEStrue if the user has enabled Darken Colors in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether grayscale is enabled.

    Declaration

    Swift

    func UIAccessibilityIsGrayscaleEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsGrayscaleEnabled ( void );

    Return Value

    YEStrue if the user has enabled Grayscale in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether Guided Access is enabled.

    Declaration

    Swift

    func UIAccessibilityIsGuidedAccessEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsGuidedAccessEnabled ( void );

    Return Value

    YEStrue if the user has enabled Guided Access in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • Returns a Boolean value indicating whether inverted colors is enabled.

    Declaration

    Swift

    func UIAccessibilityIsInvertColorsEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsInvertColorsEnabled ( void );

    Return Value

    YEStrue if the user has enabled inverted colors in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • Returns a Boolean value indicating whether system audio is set to mono.

    Declaration

    Swift

    func UIAccessibilityIsMonoAudioEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsMonoAudioEnabled ( void );

    Return Value

    YEStrue if mono audio is currently enabled; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value indicating whether reduce motion is enabled.

    Declaration

    Swift

    func UIAccessibilityIsReduceMotionEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsReduceMotionEnabled ( void );

    Return Value

    YEStrue if the user has enabled Reduce Motion in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether reduce transparency is enabled.

    Declaration

    Swift

    func UIAccessibilityIsReduceTransparencyEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsReduceTransparencyEnabled ( void );

    Return Value

    YEStrue if the user has enabled Reduce Transparency in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether speaking the screen is enabled.

    Declaration

    Swift

    func UIAccessibilityIsSpeakScreenEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsSpeakScreenEnabled ( void );

    Return Value

    YEStrue if the user has enabled Speak Screen in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether speaking the selection is enabled.

    Declaration

    Swift

    func UIAccessibilityIsSpeakSelectionEnabled() -> Bool

    Objective-C

    BOOL UIAccessibilityIsSpeakSelectionEnabled ( void );

    Return Value

    YEStrue if the user has enabled Speak Selection in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether Switch Control is enabled.

    Declaration

    Swift

    func UIAccessibilityIsSwitchControlRunning() -> Bool

    Objective-C

    BOOL UIAccessibilityIsSwitchControlRunning ( void );

    Return Value

    YEStrue if the user has enabled Switch Control in Settings; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Returns a Boolean value indicating whether VoiceOver is running.

    Declaration

    Swift

    func UIAccessibilityIsVoiceOverRunning() -> Bool

    Objective-C

    BOOL UIAccessibilityIsVoiceOverRunning ( void );

    Return Value

    YEStrue if VoiceOver is currently running; otherwise, NOfalse.

    Discussion

    You can use this function to customize your application’s UI specifically for VoiceOver users. For example, you might want UI elements that usually disappear quickly to persist onscreen for VoiceOver users. Note that you can also listen for the UIAccessibilityVoiceOverStatusChanged notification to find out when VoiceOver starts and stops.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.0 and later.

  • Converts a UIKit text alignment constant value to the matching constant value used by Core Text.

    Declaration

    Swift

    func NSTextAlignmentToCTTextAlignment(_ nsTextAlignment: NSTextAlignment) -> CTTextAlignment

    Objective-C

    CTTextAlignment NSTextAlignmentToCTTextAlignment ( NSTextAlignment nsTextAlignment );

    Parameters

    nsTextAlignment

    The UIKit text alignment constant you want to convert.

    Return Value

    The Core Text alignment that corresponds to the value specified in nsTextAlignment.

    Discussion

    Use this function when you need to map between the UIKit and Core Text constants for text alignment.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • Converts a Core Text alignment constant value to the matching constant value used by UIKit.

    Declaration

    Swift

    func NSTextAlignmentFromCTTextAlignment(_ ctTextAlignment: CTTextAlignment) -> NSTextAlignment

    Objective-C

    NSTextAlignment NSTextAlignmentFromCTTextAlignment ( CTTextAlignment ctTextAlignment );

    Parameters

    ctTextAlignment

    The Core text alignment constant you want to convert.

    Return Value

    The UIKit text alignment that corresponds to the value specified in ctTextAlignment.

    Discussion

    Use this function when you need to map between the Core Text and UIKit constants for text alignment.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.