<tfoot id='ZTDxx'></tfoot>

      <small id='ZTDxx'></small><noframes id='ZTDxx'>

      • <bdo id='ZTDxx'></bdo><ul id='ZTDxx'></ul>
      <legend id='ZTDxx'><style id='ZTDxx'><dir id='ZTDxx'><q id='ZTDxx'></q></dir></style></legend>
    1. <i id='ZTDxx'><tr id='ZTDxx'><dt id='ZTDxx'><q id='ZTDxx'><span id='ZTDxx'><b id='ZTDxx'><form id='ZTDxx'><ins id='ZTDxx'></ins><ul id='ZTDxx'></ul><sub id='ZTDxx'></sub></form><legend id='ZTDxx'></legend><bdo id='ZTDxx'><pre id='ZTDxx'><center id='ZTDxx'></center></pre></bdo></b><th id='ZTDxx'></th></span></q></dt></tr></i><div id='ZTDxx'><tfoot id='ZTDxx'></tfoot><dl id='ZTDxx'><fieldset id='ZTDxx'></fieldset></dl></div>

      暂停 UIImageview 动画

      Pause UIImageview Animation(暂停 UIImageview 动画)
      <tfoot id='GvPAf'></tfoot>

      <small id='GvPAf'></small><noframes id='GvPAf'>

          <legend id='GvPAf'><style id='GvPAf'><dir id='GvPAf'><q id='GvPAf'></q></dir></style></legend>
          <i id='GvPAf'><tr id='GvPAf'><dt id='GvPAf'><q id='GvPAf'><span id='GvPAf'><b id='GvPAf'><form id='GvPAf'><ins id='GvPAf'></ins><ul id='GvPAf'></ul><sub id='GvPAf'></sub></form><legend id='GvPAf'></legend><bdo id='GvPAf'><pre id='GvPAf'><center id='GvPAf'></center></pre></bdo></b><th id='GvPAf'></th></span></q></dt></tr></i><div id='GvPAf'><tfoot id='GvPAf'></tfoot><dl id='GvPAf'><fieldset id='GvPAf'></fieldset></dl></div>

                <bdo id='GvPAf'></bdo><ul id='GvPAf'></ul>
                  <tbody id='GvPAf'></tbody>
                本文介绍了暂停 UIImageview 动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想暂停 UIImageView 动画,根据我的研究发现,您可以停止图像的动画,但不能暂停序列.通过在 UIImageView 上调用语句 stop animating 然后它会停止动画并使图像视图空白.

                I want to pause UIImageView animation and based on my research found that you can stop the animation of the images but you cannot pause the sequence. By calling statement stop animating on the UIImageView then it stops the animation and blanks the image view.

                要暂停 UIImages 的动画,必须使用 NSTimer.

                To pause the animation of UIImages one has to use NSTimer.

                我已经在应用程序中使用了一个 NSTimer 来以不同的时间间隔一个接一个地加载 view controllers.我在每个 view controller 中有一个 UIImages 的幻灯片.

                I m already using one NSTimer in app for loading view controllers one after the other at different time intervals. I have a slide show of UIImages in each view controller.

                问题是 Timer 暂停时 view controllers 暂停加载,但当时显示的 view controller 仍然显示 的幻灯片重复该 view controller 的 UIImages 直到暂停恢复.所以我也想暂停那个幻灯片.

                Issue is when Timer is paused view controllers are paused from loading further but the view controller which is on display at that time still shows the slide show of UIImages of that view controller repeatedly until pause is resumed. So I want to pause that slideshow too.

                这是我使用 NSTimer

                -(void)playpauseAction:(id)sender {
                if([audioPlayer isPlaying])
                {
                    [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
                    [audioPlayer pause];
                    [self pauseTimer];
                }else{
                    [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
                    [audioPlayer play];
                    [self resumeTimer];
                if(isFirstTime == YES)
                    {
                     self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
                                                         target:self
                                                         selector:@selector(displayviewsAction:)
                                                         userInfo:nil
                                                        repeats:NO];
                        isFirstTime  = NO;
                    }         
                    } 
                    }
                

                这就是 displayviewsAction 以不同的时间间隔依次加载 11 个视图控制器的方式

                This is how displayviewsAction loads 11 view controllers one after another at different time intervals

                - (void)displayviewsAction:(id)sender
                 {  
                 First *firstController = [[First alloc] init];
                 firstController.view.frame = CGRectMake(0, 0, 320, 480);
                 CATransition *transitionAnimation = [CATransition animation];
                 [transitionAnimation setDuration:1];
                 [transitionAnimation setType:kCATransitionFade];
                 [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
                 [self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade];
                 [self.view addSubview:firstController.view];
                 [self.view addSubview:toolbar];
                 [firstController release];   
                 self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO];     
                
                 }
                
                 -(void)Second 
                {
                Second *secondController = [[Second alloc] init];
                secondController.view.frame = CGRectMake(0, 0, 320, 480);
                CATransition *transitionAnimation = [CATransition animation];
                [transitionAnimation setDuration:1];
                [transitionAnimation setType:kCATransitionReveal];
                [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
                [self.view.layer addAnimation:transitionAnimation forKey:kCATransitionReveal];
                [self.view addSubview:secondController.view]; 
                [self.view addSubview:toolbar];
                [secondController release];
                self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
                }
                

                这就是在视图控制器中启动图像动画的方式

                And that is how starting image animation within the view controller

                // Displays UIImageView
                UIImageView* ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 300, 235)];
                self.view.backgroundColor = [UIColor brownColor];
                // load all the frames of our animation
                ImageView.animationImages = [NSArray arrayWithObjects:    
                                                [UIImage imageNamed:@"1a.png"],
                                                [UIImage imageNamed:@"1b.png"],
                                                nil];
                
                 // all frames will execute in 25 seconds
                 ImageView.animationDuration = 25;
                // start animating
                [ImageView startAnimating];
                ImageView.layer.borderWidth = 2;
                ImageView.layer.borderColor = [[UIColor whiteColor]CGColor];
                [ImageView.layer setMasksToBounds:YES];
                [ImageView.layer setCornerRadius:15.0f];
                [baseView addSubview:ImageView]; 
                

                现在,如果有人可以指导我如何在此 NSTimer 暂停时暂停此 UIImage 动画 幻灯片.

                Now if someone can guide me how to pause this slideshow of UIImage animation when this NSTimer pauses.

                感谢您的帮助.

                推荐答案

                你可以使用苹果提供的代码来暂停和恢复你的动画.

                you can use the code provided by apple to pause and resume your animation.

                -(void)pauseLayer:(CALayer*)layer
                {
                CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
                layer.speed = 0.0;
                layer.timeOffset = pausedTime;
                }
                
                -(void)resumeLayer:(CALayer*)layer
                {
                CFTimeInterval pausedTime = [layer timeOffset];
                layer.speed = 1.0;
                layer.timeOffset = 0.0;
                layer.beginTime = 0.0;
                CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
                layer.beginTime = timeSincePause;
                }
                

                而要让CALayer传递给pauseLayer函数,可以使用以下代码.

                And to get the CALayer to pass to the pauseLayer function, you can use the following code.

                CALayer *player = ImageView.layer;
                [self pauseLayer:player];
                

                希望对你有帮助.

                这篇关于暂停 UIImageview 动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                How to copy a quot;Dictionaryquot; in Swift?(如何复制“字典在斯威夫特?)
                When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                Android file copy(安卓文件拷贝)
                Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)

                  <i id='sQUqh'><tr id='sQUqh'><dt id='sQUqh'><q id='sQUqh'><span id='sQUqh'><b id='sQUqh'><form id='sQUqh'><ins id='sQUqh'></ins><ul id='sQUqh'></ul><sub id='sQUqh'></sub></form><legend id='sQUqh'></legend><bdo id='sQUqh'><pre id='sQUqh'><center id='sQUqh'></center></pre></bdo></b><th id='sQUqh'></th></span></q></dt></tr></i><div id='sQUqh'><tfoot id='sQUqh'></tfoot><dl id='sQUqh'><fieldset id='sQUqh'></fieldset></dl></div>

                  <legend id='sQUqh'><style id='sQUqh'><dir id='sQUqh'><q id='sQUqh'></q></dir></style></legend>
                    <tbody id='sQUqh'></tbody>

                    <small id='sQUqh'></small><noframes id='sQUqh'>

                          <bdo id='sQUqh'></bdo><ul id='sQUqh'></ul>
                          <tfoot id='sQUqh'></tfoot>