1

我有一个要求,比如在 tableView 单元格上点击它应该动画并丢弃(跳转)到垃圾图标。

我正在使用UIBezierPath动画文本和跳转功能,但我无法移动 tableViewCell 内的标签。

任何想法和建议将不胜感激。

到目前为止,请检查以下代码。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableArray  *views=[[NSMutableArray alloc]init];
    int i=0;
    int j=indexPath.row;
    UIView *anim = nil;
    UIView *vi2;
    for (UIView *theview in destination.superview.subviews) 
    {
//                if (theview.tag != 2)
//                    continue;
        NSLog(@"%@",theview);
        if ([theview isKindOfClass:[UITableView class]]) 
        {
           // NSLog(@"%@",theview);
            UIView *vi= theview;//(UITableView *)[UITableView class];
           // NSLog(@"%@",vi);

           // NSMutableArray  *views=[[NSMutableArray alloc]init];
            for(UIView *vi1 in vi.subviews )
            {
                NSLog(@" the current view....%@",vi1);
                for (int k = 0; k < [arrayList count]; k++)
                {
                    [views insertObject:vi1 atIndex:i++];
                    NSLog(@" ddddd %@",[views objectAtIndex:i-1]);

                }
               }
              //  vi1=(UITableViewCell*)[tableElements objectAtIndex:i];
                anim=(UIView *)[views objectAtIndex:j];
                anim = vi2;   

            for (int k = 0; k < [views count]; k++)
                NSLog (@"Element %d = %@", k, [views objectAtIndex: k]); 



            break;
          }
        }

    if (!anim)
        return;

    UIBezierPath *movePath = [UIBezierPath bezierPath];
    [movePath moveToPoint:anim.center];
    [movePath addQuadCurveToPoint:destination.center
                     controlPoint:CGPointMake(destination.center.x, anim.center.y)];

    CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    moveAnim.path = movePath.CGPath;
    moveAnim.removedOnCompletion = YES;

    CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
    scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
    scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
    scaleAnim.removedOnCompletion = YES;

    CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
    opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
    opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
    opacityAnim.removedOnCompletion = YES;

    CAAnimationGroup *animGroup = [CAAnimationGroup animation];
    animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim, opacityAnim, nil];
    animGroup.duration = 0.5;
    [anim.layer addAnimation:animGroup forKey:nil];
}

阿伦..

4

1 回答 1

1

我可以建议对您的单元格进行快照并将其作为 UIImageView 放在层次结构中的当前主视图上(主要是 self.view)。您按原样从表格中删除单元格,但为该 UIImageView 应用动画。当我尝试使用 UITableViews 进行拖放时,我已经完成了这个技巧。

于 2012-01-30T10:22:57.480 回答