0

360度/no.of.Imageviewsを分割して各Imageviewを回転させる角度を取得する複数の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;
}

ここで私の問題は、すべての画像ビューが一度にアニメーション化を開始することです。画像ビューを次々とある角度に回転させたい。

どんなアイデアでもありがたいです、ありがとう

4

0 に答える 0