0

我需要实现的动画。 请帮我。

我尝试了很多方法但无法顺利完成,我是动画中的新手,任何帮助将不胜感激。

我试过的代码:

我需要在两个数组中添加按钮和标签。eventBtnsPopUpArray 和 eventLabelsPopUpArray。我尝试将它们添加到循环中,并且动画不流畅。

if ([eventBtnsPopUpArray count]>0)
{           

    CABasicAnimation* scalingAnimation;
    scalingAnimation = [CABasicAnimation animationWithKeyPath:@"frame.size"];;
    scalingAnimation.fromValue = [NSNumber numberWithFloat:0];
    scalingAnimation.toValue = [NSNumber numberWithFloat:1024];
    scalingAnimation.duration = 5.0;
    scalingAnimation.cumulative = YES;
    scalingAnimation.removedOnCompletion = NO;
    scalingAnimation.fillMode = kCAFillModeForwards;
    [calendarEventView.layer addAnimation:scalingAnimation forKey:@"rotationAnimation"];


  for (int k=0; k<[eventBtnsPopUpArray count]; k++)
{
    UIButton *btn = [eventBtnsPopUpArray objectAtIndex:0];
    UILabel *lbl = [eventLabelsPopUpArray objectAtIndex:0];



    [UIView animateWithDuration:2
                          delay:0
                        options: UIViewAnimationCurveEaseOut
                     animations:^{

                         [self addSubview:btn];
                         [self addSubview:lbl];

                     }
                     completion:^(BOOL finished){
                         [self pauseLayer:calendarEventView.layer];

                         [self resumeLayer:calendarEventView.layer];
                     }
     ];


}


if (calendarEventView.frame.size.width < 1024) {
    [UIView beginAnimations:@"DrawLineTillEnd" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    calendarEventView.frame = CGRectMake(0, 65, 1024, 7);
    [UIView commitAnimations];
}
}

//暂停和恢复图层功能

    -(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;
    }
4

2 回答 2

0

我认为您不需要使用核心动画,只需使用 NSTimer 并使用更改变量调整 UIView 的框架(宽度)......检查宽度的简单条件语句(if-statement)可以将其停止在某个点并添加第一个所需的 UIButton。单击此按钮将更改一个布尔值,这将触发 NSTimer 中的代码继续行增长,直到达到下一个 if 语句定义的下一个宽度。等等

于 2013-02-20T06:40:05.837 回答
0

我不知道如何使用 coreplot 或 coreanimation 来做到这一点,但是通过查看动画来做到这一点真的很简单

例如

-(void)animateLine{
   UILabel *labelObj = [[UiLabel alloc]init];
   //Set background image and height of label say 100 pixel
   for(int incrementer = 0; incrementer<100; incrementer ++)
    {
         [UIView beginAnimations:nil context:nil];
         [UIView setAnimationDuration:0.01];
         [labelObj setFrame:cgRectMake(0,100,incrementer,20)];
         [uiview commitAnimation];
    }
}
于 2013-02-20T06:42:25.943 回答