UIImageWriteToSavedPhotosAlbum
UIImageWriteToSavedPhotosAlbum:
UIKit Function Reference
Overview
The UIKit framework defines a number of functions, many of them used in graphics and drawing operations.
Functions by Task
Application Launch
Image Manipulation
Image and Movie Saving
UIImageWriteToSavedPhotosAlbum
UISaveVideoAtPathToSavedPhotosAlbum
UIVideoAtPathIsCompatibleWithSavedPhotosAlbum
Graphics
UIGraphicsGetCurrentContext
UIGraphicsPushContext
UIGraphicsPopContext
UIGraphicsBeginImageContext
UIGraphicsBeginImageContextWithOptions
UIGraphicsGetImageFromCurrentImageContext
UIGraphicsEndImageContext
UIRectClip
UIRectFill
UIRectFillUsingBlendMode
UIRectFrame
UIRectFrameUsingBlendMode
Creating a Dictionary
PDF Creation
UIGraphicsBeginPDFContextToData
UIGraphicsBeginPDFContextToFile
UIGraphicsEndPDFContext
UIGraphicsBeginPDFPage
UIGraphicsBeginPDFPageWithInfo
UIGraphicsGetPDFContextBounds
UIGraphicsAddPDFContextDestinationAtPoint
UIGraphicsSetPDFContextDestinationForRect
UIGraphicsSetPDFContextURLForRect
String Conversions
CGAffineTransformFromString
CGPointFromString
CGRectFromString
CGSizeFromString
NSStringFromCGAffineTransform
NSStringFromCGPoint
NSStringFromCGRect
NSStringFromCGSize
NSStringFromUIEdgeInsets
NSStringFromUIOffset
UIEdgeInsetsFromString
UIOffsetFromString
Managing Edge Insets
Managing Offsets
Interface Orientation Macros
Device Orientation Macros
UIDeviceOrientationIsValidInterfaceOrientation
UIDeviceOrientationIsPortrait
UIDeviceOrientationIsLandscape
Interface Idiom Macro
Accessibility
UIAccessibilityPostNotification
UIAccessibilityIsVoiceOverRunning
UIAccessibilityIsClosedCaptioningEnabled
UIAccessibilityRequestGuidedAccessSession
UIAccessibilityIsGuidedAccessEnabled
UIAccessibilityIsInvertColorsEnabled
UIAccessibilityIsMonoAudioEnabled
UIAccessibilityZoomFocusChanged
UIAccessibilityRegisterGestureConflictWithZoom
UIAccessibilityConvertFrameToScreenCoordinates
UIAccessibilityConvertPathToScreenCoordinates
Text Manipulations
Guided Access Restriction State
Functions
CGAffineTransformFromString
Returns a Core Graphics affine transform structure corresponding to the data in a given string.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
CGPointFromString
Returns a Core Graphics point structure corresponding to the data in a given string.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
CGRectFromString
Returns a Core Graphics rectangle structure corresponding to the data in a given string.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
CGSizeFromString
Returns a Core Graphics size structure corresponding to the data in a given string.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
NSDictionaryOfVariableBindings
Creates a dictionary wherein the keys are string representations of the corresponding values’ variable names.
#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 }.
Availability
- Available in iOS 6.0 and later.
Related Sample Code
Declared In
NSLayoutConstraint.h
NSStringFromCGAffineTransform
Returns a string formatted to contain the data from an affine transform.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
NSStringFromCGPoint
Returns a string formatted to contain the data from a point.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
NSStringFromCGRect
Returns a string formatted to contain the data from a rectangle.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Related Sample Code
Declared In
UIGeometry.h
NSStringFromCGSize
Returns a string formatted to contain the data from a size data structure.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
NSStringFromUIEdgeInsets
Returns a string formatted to contain the data from an edge insets structure.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
NSStringFromUIOffset
Returns a string formatted to contain the data from an offset structure.
NSString *NSStringFromUIOffset(
UIOffset offset
);
Parameters
- offset
-
A UIKit offset data structure.
Return Value
A string that corresponds to offset.
Availability
- Available in iOS 5.0 and later.
See Also
Declared In
UIGeometry.h
NSTextAlignmentFromCTTextAlignment
Converts a Core Text alignment constant value to the matching constant value used by UIKit.
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.
Availability
- Available in iOS 6.0 and later.
Declared In
NSText.h
NSTextAlignmentToCTTextAlignment
Converts a UIKit text alignment constant value to the matching constant value used by Core Text.
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.
Availability
- Available in iOS 6.0 and later.
Declared In
NSText.h
UIAccessibilityConvertFrameToScreenCoordinates
Converts the specified rectangle from view coordinates to screen coordinates.
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.
Availability
- Available in iOS 7.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityConvertPathToScreenCoordinates
Converts the specified path object to screen coordinates and returns a new path object with the results.
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 specifiedview. 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.
Availability
- Available in iOS 7.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityIsClosedCaptioningEnabled
Returns a Boolean value indicating whether closed captioning is enabled.
BOOL UIAccessibilityIsClosedCaptioningEnabled();
Return Value
YES
if the user has enabled closed captioning in Settings; otherwise, NO
.
Availability
- Available in iOS 5.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityIsGuidedAccessEnabled
Returns a Boolean value indicating whether Guided Access is enabled.
BOOL UIAccessibilityIsGuidedAccessEnabled();
Return Value
YES
if the user has enabled Guided Access in Settings; otherwise, NO
.
Availability
- Available in iOS 6.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityIsInvertColorsEnabled
Returns a Boolean value indicating whether inverted colors is enabled.
BOOL UIAccessibilityIsInvertColorsEnabled();
Return Value
YES
if the user has enabled inverted colors in Settings; otherwise, NO
.
Availability
- Available in iOS 6.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityIsMonoAudioEnabled
Returns a Boolean value indicating whether system audio is set to mono.
BOOL UIAccessibilityIsMonoAudioEnabled();
Return Value
YES
if mono audio is currently enabled; otherwise, NO
.
Availability
- Available in iOS 5.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityIsVoiceOverRunning
Returns a Boolean value indicating whether VoiceOver is running.
BOOL UIAccessibilityIsVoiceOverRunning();
Return Value
YES
if VoiceOver is currently running; otherwise, NO
.
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.
Availability
- Available in iOS 4.0 and later.
Declared In
UIAccessibility.h
UIAccessibilityPostNotification
Posts a notification to assistive applications.
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.
Availability
- Available in iOS 3.0 and later.
Related Sample Code
Declared In
UIAccessibility.h
UIAccessibilityRegisterGestureConflictWithZoom
Warns users that application-specific gestures conflict with the system-defined Zoom accessibility gestures.
void UIAccessibilityRegisterGestureConflictWithZoom();
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.
Availability
- Available in iOS 5.0 and later.
Declared In
UIAccessibilityZoom.h
UIAccessibilityRequestGuidedAccessSession
Transitions the app to or from Single App mode asynchronously.
void UIAccessibilityRequestGuidedAccessSession(BOOL enable, void(^completionHandler)(BOOL didSucceed))
Parameters
- enable
-
Specify
YES
to put the device into Single App mode for this app orNO
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
YES
, the app transitioned to or from Single App mode successfully. IfNO
, 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 thecompletionHandler block.
Availability
- Available in iOS 7.0 and later.
See Also
Declared In
UIAccessibility.h
UIAccessibilityZoomFocusChanged
Notifies the system that the app’s focus has changed to a new location.
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.
Availability
- Available in iOS 5.0 and later.
Declared In
UIAccessibilityZoom.h
UIApplicationMain
This function is called in the main
entry point to create the application object and the application delegate and set up the event cycle.
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 specifynil
,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. Specifynil
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 iOS App Programming Guide.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIApplication.h
UIDeviceOrientationIsLandscape
Returns a Boolean value indicating whether the device is in a landscape orientation.
#define UIDeviceOrientationIsLandscape(orientation) \
((orientation) == UIDeviceOrientationLandscapeLeft || \
(orientation) == UIDeviceOrientationLandscapeRight)
Parameters
- orientation
-
Specify the value of the
orientation
property of theUIDevice
class.
Return Value
Returns YES
if the device orientation is landscape, otherwise returns NO
.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIDevice.h
UIDeviceOrientationIsPortrait
Returns a Boolean value indicating whether the device is in a portrait orientation.
#define UIDeviceOrientationIsPortrait(orientation) \
((orientation) == UIDeviceOrientationPortrait || \
(orientation) == UIDeviceOrientationPortraitUpsideDown)
Parameters
- orientation
-
Specify the value of the
orientation
property of theUIDevice
class.
Return Value
Returns YES
if the device orientation is portrait, otherwise returns NO
.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIDevice.h
UIDeviceOrientationIsValidInterfaceOrientation
Returns a Boolean value indicating whether the specified orientation constant is valid.
#define UIDeviceOrientationIsValidInterfaceOrientation(orientation) \
((orientation) == UIDeviceOrientationPortrait || \
(orientation) == UIDeviceOrientationPortraitUpsideDown || \
(orientation) == UIDeviceOrientationLandscapeLeft || \
(orientation) == UIDeviceOrientationLandscapeRight)
Parameters
- orientation
-
Specify the orientation constant to check.
Return Value
Returns YES
if the specified orientation constant is valid or NO
if it is not valid.
Availability
- Available in iOS 2.0 and later.
Declared In
UIApplication.h
UIEdgeInsetsEqualToEdgeInsets
Compares two edge insets to determine if they are the same.
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
YES
if the edge insets are the same; otherwise, NO
.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
UIEdgeInsetsFromString
Returns a UIKit edge insets structure corresponding to the data in a given string.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
UIEdgeInsetsInsetRect
Adjusts a rectangle by the given edge insets.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGeometry.h
UIEdgeInsetsMake
Creates an edge inset for a button or view.
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.
Availability
- Available in iOS 2.0 and later.
See Also
Related Sample Code
Declared In
UIGeometry.h
UIGraphicsAddPDFContextDestinationAtPoint
Creates a jump destination in the current page.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsBeginImageContext
Creates a bitmap-based graphics context and makes it the current context.
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 NO
and a scale factor of1.0
.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIGraphics.h
UIGraphicsBeginImageContextWithOptions
Creates a bitmap-based graphics context with the specified options.
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
YES
to ignore the alpha channel and optimize the bitmap’s storage. SpecifyingNO
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 as follows:
For bitmaps created in iOS 3.2 and later, the drawing environment uses the premultiplied ARGB format to store the bitmap data. If the opaque parameter is
YES
, the bitmap is treated as fully opaque and its alpha channel is ignored.For bitmaps created in iOS 3.1.x and earlier, the drawing environment uses the premultiplied RGBA format to store the bitmap data.
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 theUIGraphicsPopContext
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.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 4.0 and later.
See Also
Related Sample Code
Declared In
UIGraphics.h
UIGraphicsBeginPDFContextToData
Creates a PDF-based graphics context that targets the specified mutable data object.
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.
Availability
- Available in iOS 3.2 and later.
See Also
Declared In
UIGraphics.h
UIGraphicsBeginPDFContextToFile
Creates a PDF-based graphics context that targets a file at the specified path.
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
YES
if the PDF context was created successfully or NO
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsBeginPDFPage
Marks the beginning of a new page in a PDF context and configures it using default values.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsBeginPDFPageWithInfo
Marks the beginning of a new page in a PDF context and configures it using the specified values.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsEndImageContext
Removes the current bitmap-based graphics context from the top of the stack.
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.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 2.0 and later.
See Also
Related Sample Code
Declared In
UIGraphics.h
UIGraphicsEndPDFContext
Closes a PDF graphics context and pops it from the current context stack.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsGetCurrentContext
Returns the current graphics context.
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.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIGraphics.h
UIGraphicsGetImageFromCurrentImageContext
Returns an image based on the contents of the current bitmap-based graphics context.
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
.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 2.0 and later.
See Also
Related Sample Code
Declared In
UIGraphics.h
UIGraphicsGetPDFContextBounds
Returns the current page bounds.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsPopContext
Removes the current graphics context from the top of the stack, restoring the previous context.
void UIGraphicsPopContext (
void
);
Discussion
Use this function to balance calls to the UIGraphicsPushContext
function.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGraphics.h
UIGraphicsPushContext
Makes the specified graphics context the current context.
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.
In iOS 4 and later, you may call this function from any thread of your app.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
UIGraphics.h
UIGraphicsSetPDFContextDestinationForRect
Links a rectangle on the current page to the specified jump destination.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGraphicsSetPDFContextURLForRect
Links a rectangle on the current page to the specified URL.
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.
Availability
- Available in iOS 3.2 and later.
Declared In
UIGraphics.h
UIGuidedAccessRestrictionStateForIdentifier
Returns the restriction state for the specified guided access restriction.
UIGuidedAccessRestrictionState UIGuidedAccessRestrictionStateForIdentifier(NSString *restrictionIdentifier);
Parameters
- restrictionIdentifier
-
The string that uniquely identifies the guided access restriction.
Return Value
The current state of the guided access restriction. The initial state of all restrictions is UIGuidedAccessRestrictionStateAllow
.
Availability
- Available in iOS 7.0 and later.
Declared In
UIGuidedAccessRestrictions.h
UIImageJPEGRepresentation
Returns the data for the specified image in JPEG format.
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.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIImage.h
UIImagePNGRepresentation
Returns the data for the specified image in PNG format
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.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UIImage.h
UIImageWriteToSavedPhotosAlbum
Adds the specified image to the user’s Camera Roll album.
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.
UIImageWriteToSavedPhotosAlbum的更多相关文章
- ios UIImageWriteToSavedPhotosAlbum报错 NSPhotoLibraryAddUsageDescription
最近学习IOS相关知识. 视频课程[UIImage](https://www.imooc.com/video/12718) 相关知识点: 存储一张本地图片到系统相册中. API: UIImageWri ...
- iOS10 UIImageWriteToSavedPhotosAlbum程序奔溃crash解决办法
Xcode报错: This app has crashed because it attempted to access privacy-sensitive data without a usage ...
- iOS开发系列--打造自己的“美图秀秀”
--绘图与滤镜全面解析 概述 在iOS中可以很容易的开发出绚丽的界面效果,一方面得益于成功系统的设计,另一方面得益于它强大的开发框架.今天我们将围绕iOS中两大图形.图像绘图框架进行介绍:Quartz ...
- iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总
--系统应用与系统服务 iOS开发过程中有时候难免会使用iOS内置的一些应用软件和服务,例如QQ通讯录.微信电话本会使用iOS的通讯录,一些第三方软件会在应用内发送短信等.今天将和大家一起学习如何使用 ...
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
--iOS多媒体 概览 随着移动互联网的发展,如今的手机早已不是打电话.发短信那么简单了,播放音乐.视频.录音.拍照等都是很常用的功能.在iOS中对于多媒体的支持是非常强大的,无论是音视频播放.录制, ...
- iOS--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook等系统服务开发汇总
iOS开发过程中有时候难免会使用iOS内置的一些应用软件和服务,例如QQ通讯录.微信电话本会使用iOS的通讯录,一些第三方软件会在应用内发送短信等.今天将和大家一起学习如何使用系统应用.使用系统服务: ...
- iOS开发之画图板(贝塞尔曲线)
贝塞尔曲线,听着挺牛气一词,不过下面我们在做画图板的时候就用到贝塞尔绘直线,没用到绘制曲线的功能.如果会点PS的小伙伴会对贝塞尔曲线有更直观的理解.这篇博文的重点不在于如何用使用贝塞尔曲线,而是利用贝 ...
- iOS 简单滤镜
转自:http://blog.csdn.net/lovechris00/article/details/51496458 1.主要是运用 ImageUtil库,把原图通过矩阵色值设置层不同滤镜效果下的 ...
- iOS,多媒体,地图相关
1.本地音频播放 2.本地视频播放 3.使用UIImagePickerController摄像头拍照,录像,照片库浏览 4.使用AVFunction,AVCaptureVideoDataOutput实 ...
随机推荐
- C# httprequest post 内容有百分号,部分特殊字符乱码问题
哎没办法,还没完全脱离.net,已经一半了. http://stackoverflow.com/questions/7908581/how-to-encode-http-post-parameters ...
- C#学校班级自动升级实现代码
代码逻辑如下: //班级自动升级 //获取该学校还没有毕业的班级 List<ClassInfoes> classinfoeslist = classinfoesbll.GetList(Sc ...
- php计算两个日期相差 年 月 日
在PHP程序中,很多时候都会遇到处理时间的问题,比如:判断用户在线了多长时间,共登录了多少天,两个帖子发布的时间差或者是不同操作之间的日志记录等等.在文章中,简单地举例介绍了PHP中如何计算两个日期相 ...
- openlayers 学习笔记之1
1. 为Web Gis客户端开发的javascript 框架 百度文库中的教程:入门经典> 1) 初始化map: map = new OpenLayers.Map(mapContainerNam ...
- 相似性度量(Similarity Measurement)与“距离”(Distance)
在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间的“距离”(Distance).采用什么样的方法计算距离是很讲究,甚至关 ...
- iptables交互配置shell脚本
#!/bin/bash while true do clear echo "———————-menu————————" echo -e "\033[49;32;1m(1) ...
- Java 中的 static 使用之静态变量
大家都知道,我们可以基于一个类创建多个该类的对象,每个对象都拥有自己的成员,互相独立.然而在某些时候,我们更希望该类所有的对象共享同一个成员.此时就是 static 大显身手的时候了!! Java 中 ...
- 《BI那点儿事》运用标准计分和离差——分析三国超一流统帅综合实力排名 绝对客观,数据说话
数据分析基础概念:标准计分: 1.无论作为变量的满分为几分,其标准计分的平均数势必为0,而其标准差势必为1.2.无论作为变量的单位是什么,其标准计分的平均数势必为0,而其标准差势必为1.公式为: 离差 ...
- STM32学习笔记(八) SPI总线(操作外部flash)
1. SPI总线简介 SPI全称串行外设接口,是一种高速,全双工,同步的外设总线:它工作在主从方式,常规需要至少4根线才能够正常工作.SPI作为基本的外设接口,在FLASH,EPPROM和一些数字通讯 ...
- 新建web工程Jdk怎么不是自己安装的, 是自带的
需要在eclipse中配置默认的jdk环境的,不要用它默认的那个,这个不能用的http://blog.csdn.net/clj198606061111/article/details/11881575 ...