Fetching image From Animating UIImageView(从动画 UIImageView 获取图像)
问题描述
我正在使用动画方法在 UIimageView 中实现幻灯片放映:
I'm using animation method of for implementing slide show in UIimageView as:
mainSlideShowImageView.animationImages=images;
mainSlideShowImageView.animationDuration = 75.00;
mainSlideShowImageView.animationRepeatCount = 0; //infinite
[mainSlideShowImageView startAnimating];
现在,我想知道哪个图像当前在图像视图屏幕上.
Now, what I want is to know which image is currently on image view screen.
我该怎么做?
如果不可能,也请告诉.
If it is not possible please tell that too.
'images' 这里是 UIImage 数组.
'images' here is array of UIImage.
推荐答案
AFAIK,没有返回 imageview 的当前图像的方法,但是我已经为此创建了一个解决方法....
AFAIK, there is no method which returns imageview's current image , however I have 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
}
我在这里拍摄了 5 张图像,动画持续时间为 15 ,这意味着图像将每 3 秒更改一次,所以我让计时器每 3 秒触发一次……并且由于数组包含 5 张图像……所以如果'i' 超过 4 我在方法增加中将其放回 0
I have taken 5 images here and animation duration of 15 , that means image will change at every 3 seconds, so I have kept timer to fire at every 3 seconds ... and since array contains 5 images ... so if 'i' goes beyond 4 I have put it back to 0 in method increase
这篇关于从动画 UIImageView 获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从动画 UIImageView 获取图像


基础教程推荐
- 如何使 UINavigationBar 背景透明? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01