| Framework | UIKit/UIKit.h |
| Declared in | UIAccessibility.h UIApplication.h UIDevice.h UIGeometry.h UIGraphics.h UIImage.h UIImagePickerController.h |
The UIKit framework defines a number of functions, many of them used in graphics and drawing operations.
UIGraphicsGetCurrentContext
UIGraphicsPushContext
UIGraphicsPopContext
UIGraphicsBeginImageContext
UIGraphicsGetImageFromCurrentImageContext
UIGraphicsEndImageContext
UIRectClip
UIRectFill
UIRectFillUsingBlendMode
UIRectFrame
UIRectFrameUsingBlendMode
CGPointFromString
CGRectFromString
CGSizeFromString
CGAffineTransformFromString
UIEdgeInsetsFromString
NSStringFromCGPoint
NSStringFromCGRect
NSStringFromCGSize
NSStringFromCGAffineTransform
NSStringFromUIEdgeInsets
UIDeviceOrientationIsValidInterfaceOrientation
UIDeviceOrientationIsPortrait
UIDeviceOrientationIsLandscape
Returns a Core Graphics affine transform structure corresponding to the data in a given string.
CGAffineTransform CGAffineTransformFromString ( NSString *string );
A string object 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 separate with a comma. For information about the position of each value in the transform array, see CGAffineTransform Reference.
A Core Graphics affine transform structure. If the string is not well-formed, the function returns the identity transform.
In general, you should use this function only to convert strings that were previously created using the NSStringFromCGAffineTransform function.
UIGeometry.hReturns a Core Graphics point structure corresponding to the data in a given string.
CGPoint CGPointFromString ( NSString *string );
A string object 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 separate with a comma.
A Core Graphics structure that represents a point. If the string is not well-formed, the function returns CGPointZero.
In general, you should use this function only to convert strings that were previously created using the NSStringFromCGPoint function.
UIGeometry.hReturns a Core Graphics rectangle structure corresponding to the data in a given string.
CGRect CGRectFromString ( NSString *string );
A string object 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 separate with a comma.
A Core Graphics structure that represents a rectangle. If the string is not well-formed, the function returns CGRectZero.
In general, you should use this function only to convert strings that were previously created using the NSStringFromCGRect function.
UIGeometry.hReturns a Core Graphics size structure corresponding to the data in a given string.
CGSize CGSizeFromString ( NSString *string );
A string object 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 separate with a comma.
A Core Graphics structure that represents a size. If the string is not well-formed, the function returns CGSizeZero.
In general, you should use this function only to convert strings that were previously created using the NSStringFromCGSize function.
UIGeometry.hReturns a string object formatted to contain the data from an affine transform.
NSString *NSStringFromCGAffineTransform(CGAffineTransform transform);
A Core Graphics affine transform structure.
A string object that corresponds to transform. See CGAffineTransformFromString for a discussion of the string format.
UIGeometry.hReturns a string object formatted to contain the data from a point.
NSString * NSStringFromCGPoint ( CGPoint point );
A Core Graphics structure representing a point.
A string object that corresponds to point. See CGPointFromString for a discussion of the string format.
UIGeometry.hReturns a string object formatted to contain the data from a rectangle.
NSString * NSStringFromCGRect ( CGRect rect );
A Core Graphics structure representing a rectangle.
A string object that corresponds to rect. See CGRectFromString for a discussion of the string format.
UIGeometry.hReturns a string object formatted to contain the data from a size data structure.
NSString * NSStringFromCGSize ( CGSize size );
A Core Graphics structure representing a size.
A string object that corresponds to size. See CGSizeFromString for a discussion of the string format.
UIGeometry.hReturns a string object formatted to contain the data from an edge insets structure.
NSString *NSStringFromUIEdgeInsets(UIEdgeInsets insets);
A UIKit edge insets data structure.
A string object that corresponds to insets. See UIEdgeInsetsFromString for a discussion of the string format.
UIGeometry.hPosts a notification to assistive applications.
void UIAccessibilityPostNotification(UIAccessibilityNotifications notification, id argument);
The notification to post (see “Notifications” in UIAccessibility Protocol Reference for a list of notifications).
The argument specified by the notification. Pass nil unless a notification specifies otherwise.
Your application might need to post accessibility notifications if you have user interface components that change very frequently or that appear and disappear.
UIAccessibility.hThis 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 );
The count of arguments in argv; this usually is the corresponding parameter to main.
A variable list of arguments; this usually is the corresponding parameter to main.
The name of the UIApplication class or subclass. If you specify nil, UIApplication is assumed.
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.
Even though an integer return type is specified, this function never returns. When users terminate an iPhone application by pressing the Home button, the application immediately exits by calling the exit system function with an argument of zero.
This function instantiates the application object from the principal class and 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 “The Core Application” in iPhone Application Programming Guide.
UIApplication.hReturns a Boolean value indicating whether the device is in a landscape orientation.
#define UIDeviceOrientationIsLandscape(orientation) \ ((orientation) == UIDeviceOrientationLandscapeLeft || \ (orientation) == UIDeviceOrientationLandscapeRight)
Specify the value of the orientation property of the UIDevice class.
Returns YES if the device orientation is landscape, otherwise returns NO.
UIDevice.hReturns a Boolean value indicating whether the device is in a portrait orientation.
#define UIDeviceOrientationIsPortrait(orientation) \ ((orientation) == UIDeviceOrientationPortrait || \ (orientation) == UIDeviceOrientationPortraitUpsideDown)
Specify the value of the orientation property of the UIDevice class.
Returns YES if the device orientation is portrait, otherwise returns NO.
UIDevice.hReturns a Boolean value indicating whether the specified orientation constant is valid.
#define UIDeviceOrientationIsValidInterfaceOrientation(orientation) \ ((orientation) == UIDeviceOrientationPortrait || \ (orientation) == UIDeviceOrientationPortraitUpsideDown || \ (orientation) == UIDeviceOrientationLandscapeLeft || \ (orientation) == UIDeviceOrientationLandscapeRight)
Specify the orientation constant to check.
Returns YES if the specified orientation constant is valid or NO if it is not valid.
UIApplication.hCompares two edge insets to determine if they are the same.
BOOL UIEdgeInsetsEqualToEdgeInsets ( UIEdgeInsets insets1, UIEdgeInsets insets2 );
An edge inset to compare with insets2.
An edge inset to compare with insets1.
YES if the edge insets are the same; otherwise, NO.
UIGeometry.hReturns a UIKit edge insets structure corresponding to the data in a given string.
UIEdgeInsets UIEdgeInsetsFromString ( NSString *string );
A string object 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 separate with a comma.
An edge insets data structure. If the string is not well-formed, the function returns UIEdgeInsetsZero.
In general, you should use this function only to convert strings that were previously created using the NSStringFromUIEdgeInsets function.
UIGeometry.hAdjusts a rectangle by the given edge insets.
CGRect UIEdgeInsetsInsetRect ( CGRect rect, UIEdgeInsets insets );
The rectangle to be adjusted.
The edge insets to be applied to the adjustment.
A rectangle that is adjusted by the UIEdgeInsets structure passed in insets. i
This inline function increments the origin of rect and decrements the size of rect by applying the appropriate member values of the UIEdgeInsets structure.
UIGeometry.hCreates an edge inset for a button or view.
UIEdgeInsets UIEdgeInsetsMake ( CGFloat top, CGFloat left, CGFloat bottom, CGFloat right );
The inset at the top of an object.
The inset on the left of an object
The inset on the bottom of an object.
The inset on the right of an object.
An inset for a button or view
An inset is a margin around the drawing rectangle where each side (left, right, top, and bottom) can have a different value.
UIGeometry.hCreates a bitmap-based graphics context and makes it the current context.
void UIGraphicsBeginImageContext(CGSize size);
The size of the new bitmap context. This represents the size of the image returned by the UIGraphicsGetImageFromCurrentImageContext function.
You use this function to configure the drawing environment for rendering into a bitmap. This drawing environment uses the premultiplied RGBA format to store the resulting 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 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.
UIGraphics.hRemoves the current bitmap-based graphics context from the top of the stack.
void UIGraphicsEndImageContext(void);
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 method does nothing.
UIGraphics.hReturns the current graphics context.
CGContextRef UIGraphicsGetCurrentContext ( void );
The current graphics context.
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.
You should call this function from the main thread of your application only.
UIGraphics.hReturns an image based on the contents of the current bitmap-based graphics context.
UIImage* UIGraphicsGetImageFromCurrentImageContext(void);
An autoreleased image object containing the contents of the current bitmap graphics context.
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.
UIGraphics.hRemoves the current graphics context from the top of the stack, restoring the previous context.
void UIGraphicsPopContext ( void );
Use this function to balance calls to the UIGraphicsPushContext function.
You should call this function from the main thread of your application only.
UIGraphics.hMakes the specified graphics context the current context.
void UIGraphicsPushContext ( CGContextRef context );
The graphics context to make the current context.
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.
You should call this function from the main thread of your application only.
UIGraphics.hReturns the data for the specified image in JPEG format.
NSData * UIImageJPEGRepresentation ( UIImage *image, CGFloat compressionQuality );
The original image data.
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).
An autoreleased 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.
If the image object’s underlying image data has been purged, calling this method forces that data to be reloaded into memory.
UIImage.hReturns the data for the specified image in PNG format
NSData * UIImagePNGRepresentation ( UIImage *image );
The original image data.
An autoreleased 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.
If the image object’s underlying image data has been purged, calling this method forces that data to be reloaded into memory.
UIImage.hAdds the specified image to the user’s Saved Photos album.
void UIImageWriteToSavedPhotosAlbum ( UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo );
The image to write to the user’s device.
The object whose selector should be called after the image has been written to the user’s device.
The method selector, of the target object, to call. This optional method should be of the form:
- (void) image: (UIImage *) image |
didFinishSavingWithError: (NSError *) error |
contextInfo: (void *) contextInfo; |
An optional pointer to any context-specific data that you want passed to the completion selector.
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 Saved Photos album. If you do not want to be notified, pass nil for these parameters.
UIImagePickerController.hReturns a Boolean value indicating whether the user interface is currently presented in a landscape orientation.
#define UIInterfaceOrientationIsLandscape(orientation) \ ((orientation) == UIInterfaceOrientationLandscapeLeft || \ (orientation) == UIInterfaceOrientationLandscapeRight)
Specify the orientation constant to check.
Returns YES if the interface orientation is landscape, otherwise returns NO.
The interface orientation can be different than the device orientation. You typically use this macro in your view controller code to check the current orientation.
UIApplication.hReturns a Boolean value indicating whether the user interface is currently presented in a portrait orientation.
#define UIInterfaceOrientationIsPortrait(orientation) \ ((orientation) == UIInterfaceOrientationPortrait || \ (orientation) == UIInterfaceOrientationPortraitUpsideDown)
Specify the orientation constant to check.
Returns YES if the interface orientation is portrait, otherwise returns NO.
The interface orientation can be different than the device orientation. You typically use this macro in your view controller code to check the current orientation.
UIApplication.hModifies the current clipping path by intersecting it with the specified rectangle.
void UIRectClip ( CGRect 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.
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 method 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 context, push a new graphics context onto the top of the stack using the UIGraphicsPushContext function. When you are ready to restore the original clipping region, you can then use the UIGraphicsPopContext function to remove the current context and restore the previous graphics state.
You should call this function from the main thread of your application only.
UIGraphics.hFills the specified rectangle with the current color.
void UIRectFill ( CGRect rect );
The rectangle defining the area in which to draw.
Fills the specified rectangle using the fill color of the current graphics context and the kCGBlendModeCopy blend mode.
You should call this function from the main thread of your application only.
UIGraphics.hFills a rectangle with the current fill color using the specified blend mode.
void UIRectFillUsingBlendMode ( CGRect rect, CGBlendMode blendMode );
The rectangle defining the area in which to draw.
The blend mode to use during drawing.
This function draws the rectangle in the current graphics context. If the current graphics context is nil, this method does nothing.
You should call this function from the main thread of your application only.
UIGraphics.hDraws a frame around the inside of the specified rectangle.
void UIRectFrame ( CGRect rect );
The rectangle defining the area in which to draw.
This function draws a frame around the inside of rect in the fill color of the current graphics context and using the kCGBlendModeCopy 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 method 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.
You should call this function from the main thread of your application only.
UIGraphics.hDraws a frame around the inside of a rectangle using the specified blend mode.
void UIRectFrameUsingBlendMode ( CGRect rect, CGBlendMode blendMode );
The rectangle defining the area in which to draw.
The blend mode to use during drawing.
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 method 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.
You should call this function from the main thread of your application only.
UIGraphics.hAdds the movie at the specified path to the user’s Saved Photos album.
void UISaveVideoAtPathToSavedPhotosAlbum ( NSString *videoPath, id completionTarget, SEL completionSelector, void *contextInfo );
The filesystem path to the movie file you want to save to the user’s Saved Photos album.
The object whose selector should be called after the movie has been written to the user’s device.
The method selector, of the target object, to call. This optional method should be of the form:
- (void) video: (NSString *) videoPath |
didFinishSavingWithError: (NSError *) error |
contextInfo: (void *) contextInfo; |
An optional pointer to any context-specific data that you want passed to the completion selector.
Before calling this function, you should call the UIVideoAtPathIsCompatibleWithSavedPhotosAlbum function to determine if it is possible to save videos to the Saved Photos album.
UIImagePickerController.hReturns a Boolean value indicating whether the specified video can be saved to user’s Saved Photos album.
BOOL UIVideoAtPathIsCompatibleWithSavedPhotosAlbum( NSString *videoPath)
The filesystem path to the movie file you want to save.
YES if the video can be saved to the photo album or NO if it cannot.
Not all devices are able to play video files placed in the user’s Saved Photos album. So, before attempting to save videos to the user’s camera roll, you should call this function to ensure that saving the video is supported for the current device.
UIImagePickerController.hLast updated: 2009-08-04