AQGridView单元格中的自定义动画会立即发生吗?

时间:2013-02-05 21:46:04

标签: ios6 core-animation aqgridview

所以,我正在使用AQGridView。我们有自定义单元格,其中包含图像。现在我们希望图像在点击时反弹。我尝试在图像的框架上操作,但是这不起作用所以现在我正在尝试在主视图中创建一个UIImageView并给出一个路径动画,但最终发生的是视图刚出现在左上角有问题的细胞的corder。这是相关的代码。

-(void)bounce:(CoverGridCell*)v {
    UIView * w = [v.subviews objectAtIndex:0];
    UIImageView * u = [[UIImageView alloc] initWithImage:v.image];
    u.frame = [self.view convertRect:[[w.subviews objectAtIndex:0] frame] fromView:w];
    double __block y = u.frame.origin.y;
    double __block x = u.frame.origin.x;
    [self.view addSubview:u];
    CGMutablePathRef cgmp = CGPathCreateMutable();for (int j= 10; j > 0;j--) {
        CGAffineTransform t1 = CGAffineTransformMakeTranslation(0, - j*j);
        CGAffineTransform t2 = CGAffineTransformInvert(t1);
        CGPathMoveToPoint(cgmp,&t1, x, y - j * j);
        CGPathMoveToPoint(cgmp,&t2, x, y);
    }
    CGPathRef cgp = CGPathCreateCopy(cgmp);

    CGPathRelease(cgmp);

    CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath: @"position"];
    anim.duration = 5.0;
    anim.delegate = self;
    anim.path = cgp;
    anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
    [u.layer addAnimation:anim forKey:@"DoesThisMatter"];
    [u.layer setPosition:CGPointMake(x,y)];
}

1 个答案:

答案 0 :(得分:0)

这是一个线程问题,IIRC。单击一个单元格时发生的事情是冻结'Pad,直到动画结束。