Parameters

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.

Declaration

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.

Declaration

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.

Discussion

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.

Discussion

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.

Declaration

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.

Declaration

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.

Declaration

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.

Declaration

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.

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.

Declaration

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.

Import Statement

Availability

See Also

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

Declaration

Swift

funcUIGraphicsEndImageContext()

Objective-C

voidUIGraphicsEndImageContext(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.

Declaration

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.

Declaration

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.

Declaration

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.

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.

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.

Import Statement

Availability

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

Declaration

Swift

funcUIGraphicsEndPDFContext()

Objective-C

voidUIGraphicsEndPDFContext(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.

Declaration

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.

Declaration

Parameters

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.

Declaration

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.

Declaration

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.

Declaration

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.

Declaration

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.

Declaration

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.

Declaration

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.

Parameters

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.

Declaration

Swift

funcUIAccessibilityRegisterGestureConflictWithZoom()

Objective-C

voidUIAccessibilityRegisterGestureConflictWithZoom(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.

Parameters

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.

Availability

Declaration

Swift

funcUIAccessibilityIsVoiceOverRunning() -> Bool

Objective-C

BOOLUIAccessibilityIsVoiceOverRunning(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.