Att Ios Ui Imageview
## Using Image View
Image View is used to display a single image or an animated sequence of images.
Important Properties
* image
* highlightedImage
* userInteractionEnabled
* animationImages
* animationRepeatCount
* * *
## Important Methods
- (id)initWithImage:(UIImage *)image- (id)initWithImage:(UIImage *)image highlightedImage: (UIImage *)highlightedImage- (void)startAnimating- (void)stopAnimating
### Adding a Custom Method addImageView
-(void)addImageView{ UIImageView *imgview = [ initWithFrame:CGRectMake(10, 10, 300, 400)]; [imgview setImage:[UIImage imageNamed:@"AppleUSA1.jpg"]]; [imgview setContentMode:UIViewContentModeScaleAspectFit]; [self.view addSubview:imgview];}
### Adding Another Custom Method addImageViewWithAnimation
This method demonstrates how to animate images in an imageView.
-(void)addImageViewWithAnimation{ UIImageView *imgview = [ initWithFrame:CGRectMake(10, 10, 300, 400)]; // set an animation imgview.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"AppleUSA1.jpg"], [UIImage imageNamed:@"AppleUSA2.jpg"], nil]; imgview.animationDuration = 4.0; imgview.contentMode = UIViewContentModeCenter; ; [self.view addSubview:imgview];}
**Note:** We must add images named "AppleUSA1.jpg" and "AppleUSA2.jpg" to our project, which can be done by dragging the images into our navigation area listing our project files.
Update viewDidLoad in ViewController.m as follows:
(void)viewDidLoad { ; ;}
YouTip