| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iPhone OS 2.0 and later. |
| Declared in | UIImageView.h |
| Related sample code |
An image view object provides a view-based container for displaying either a single image or for animating a series of images. For animating the images, the UIImageView class provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.
New image view objects are configured to disregard user events by default. If you want to handle events in a custom subclass of UIImageView, you must explicitly change the value of the userInteractionEnabled property to YES after initializing the object.
The UIImageView class is optimized to draw its images to the display. UIImageView will not call drawRect: a subclass. If your subclass needs custom drawing code, it is recommended you use UIView as the base class.
image property
highlightedImage property
animationImages property
highlightedAnimationImages property
animationDuration property
animationRepeatCount property
– startAnimating
– stopAnimating
– isAnimating
userInteractionEnabled property
highlighted property
For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.
The amount of time it takes to go through one cycle of the images.
@property(nonatomic) NSTimeInterval animationDuration
The time duration is measured in seconds. The default value of this property is equal to the number of images multiplied by 1/30th of a second. Thus, if you had 30 images, the value would be 1 second.
UIImageView.hAn array of UIImage objects to use for an animation.
@property(nonatomic, copy) NSArray *animationImages
The array must contain UIImage objects. You may use the same image object more than once in the array. Setting this property to a value other than nil hides the image represented by the image property. The value of this property is nil by default.
The images assigned to this property are scaled, sized to fit, or positioned in the image view according to the contentMode property of the view. It is recommended (but not required) that you use images that are all the same size. If the images are different sizes, each will be adjusted to fit separately based on that mode.
@property image @property contentMode (UIView)UIImageView.hSpecifies the number of times to repeat the animation.
@property(nonatomic) NSInteger animationRepeatCount
The default value is 0, which specifies to repeat the animation indefinitely.
UIImageView.hA Boolean value that determines whether the image is highlighted.
@property(nonatomic, getter=isHighlighted) BOOL highlighted
This property determines whether the regular or highlighted images are used. When highlighted is set to YES, a non-animated image will use the highlightedImage property and an animated image will use the highlightedAnimationImages. If both of those properties are set to nil or if highlighted is set to NO, it will use the image and animationImages properties.
UIImageView.hAn array of UIImage objects to use for an animation when the view is highlighted.
@property(nonatomic, copy) NSArray *highlightedAnimationImages
The array must contain UIImage objects. You may use the same image object more than once in the array. Setting this property to a value other than nil hides the image represented by the highlightedImage property. The value of this property is nil by default.
The images assigned to this property are scaled, sized to fit, or positioned in the image view according to the contentMode property of the view. It is recommended (but not required) that you use images that are all the same size. If the images are different sizes, each will be adjusted to fit separately based on that mode.
UIImageView.hThe highlighted image displayed in the image view.
@property(nonatomic, retain) UIImage *highlightedImage
The initial value of this property is the image passed into the initWithImage:highlightedImage: method or nil if you initialized the receiver using a different method.
If the highlightedAnimationImages property contains a value other than nil, the contents of this property are not used.
UIImageView.hThe image displayed in the image view.
@property(nonatomic, retain) UIImage *image
The initial value of this property is the image passed into the initWithImage: method or nil if you initialized the receiver using a different method.
If the animationImages property contains a value other than nil, the contents of this property are not used.
Setting the image property does not change the size of a UIImageView. Call sizeToFit to adjust the size of the view to match the image.
UIImageView.hA Boolean value that determines whether user events are ignored and removed from the event queue.
@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled
This property is inherited from the UIView parent class. This class changes the default value of this property to NO.
UIImageView.hReturns an image view initialized with the specified image.
- (id)initWithImage:(UIImage *)image
The initial image to display in the image view.
An initialized image view object.
This method adjusts the frame of the receiver to match the size of the specified image. It also disables user interactions for the image view by default.
UIImageView.hReturns an image view initialized with the specified regular and highlighted images.
- (id)initWithImage:(UIImage *)imagehighlightedImage:(UIImage *)highlightedImage
The initial image to display in the image view.
The image to display if the image view is highlighted.
An initialized image view object.
This method adjusts the frame of the receiver to match the size of the specified image. It also disables user interactions for the image view by default.
UIImageView.hReturns a Boolean value indicating whether the animation is running.
- (BOOL)isAnimating
YES if the animation is running; otherwise, NO.
UIImageView.hStarts animating the images in the receiver.
- (void)startAnimating
This method always starts the animation from the first image in the list.
UIImageView.hStops animating the images in the receiver.
- (void)stopAnimating
UIImageView.hLast updated: 2009-04-30