Extract image from UIImageView animation

I am using an animation method to implement a slide show in a UIimageView like:

mainSlideShowImageView.animationImages=images; mainSlideShowImageView.animationDuration = 75.00; mainSlideShowImageView.animationRepeatCount = 0; //infinite [mainSlideShowImageView startAnimating]; 

Now I want to know which image is on the image viewing screen.

How can i do this?

If this is not possible, report it too.

Edit: The “images” here are an array of UIImage.

+4
source share
1 answer

AFAIK, there is no method that returns an image of the current image, but I created a workaround for this ....

 array= [NSArray arrayWithObjects:[UIImage imageNamed:@"1.jpg"],[UIImage imageNamed:@"2.jpg"],[UIImage imageNamed:@"3.jpg"],[UIImage imageNamed:@"4.jpg"],[UIImage imageNamed:@"5.jpg"],nil]; mainSlideShowImageView.animationImages= array; mainSlideShowImageView.animationDuration=15.0; i=0; timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(increase) userInfo:nil repeats:YES]; [mainSlideShowImageView startAnimating]; -(void)increase { i++; if (i>4) { i=0; } } -(void)getimage { UIImage* im = [array objectAtIndex:i]; // im is the current image of imageview } 

I took 5 images here and the animation duration is 15, which means the image will change every 3 seconds, so I have to hold the timer every 3 seconds ... and since the array contains 5 images ... so if 'i' goes beyond limits 4 I returned it to 0 when increasing the method

+3
source

Source: https://habr.com/ru/post/1346537/


All Articles