如何在iPhone sdk中开始动画时设置CABasicAnimation的帧速率

时间:2012-10-23 05:22:00

标签: objective-c ios5.1 cabasicanimation

我正在使用多个Imageview,我将360度/ no.of.Imageviews划分为旋转每个Imageview的角度。

#define angle ((2*M_PI)/13.0)

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    mainView.backgroundColor = [UIColor blackColor];


    for(currentIndex = 0; currentIndex < 13; currentIndex++)
    {

        UIImageView *imageView = [self getCardsWithAngle:(currentIndex*angle)];

        [mainView addSubview:imageView];
    }
}

-(UIImageView *)getCardsWithAngle:(float)aAngle 
{

    CGRect frame = CGRectMake(mainView.center.x+50, mainView.center.y-100, 250,200);
    CGPoint anchorPoint = CGPointMake(0.5,1.5);

    imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"card_1.png"]];
    imgView.frame = frame;
    imgView.backgroundColor = [UIColor clearColor];
    if(aAngle == 0.0)
    {
        imgView.layer.anchorPoint = anchorPoint;
        return imgView;
    }

    imgView.layer.anchorPoint = anchorPoint;


    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat:aAngle];
    rotationAnimation.duration = 3.0;


    rotationAnimation.removedOnCompletion = NO;
    rotationAnimation.fillMode = kCAFillModeForwards;
    rotationAnimation.delegate = self;
    [rotationAnimation setValue:[NSNumber numberWithFloat:aAngle] forKey:@"finalAngle"];

    [imgView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];



    return imgView;
}

这里我的问题是所有的图像视图一次开始制作动画。我想将图像视图一个接一个地旋转。

任何想法将不胜感激, 谢谢大家

0 个答案:

没有答案