1. 程式人生 > >UITableViewCell顯示動畫

UITableViewCell顯示動畫

CATransform3D rotation;//3D旋轉

        rotation = CATransform3DMakeTranslation(0 ,50 ,20);

//        rotation = CATransform3DMakeRotation( M_PI_4 , 0.0, 0.7, 0.4);

        //逆時針旋轉

        rotation = CATransform3DScale(rotation, 0.9, .9, 1);

        rotation.m34 = 1.0/ -600;

        cell.layer.shadowColor = [[UIColor blackColor]CGColor];

        cell.layer.shadowOffset = CGSizeMake(10, 10);

        cell.alpha = 0;

        cell.layer.transform = rotation;

        [UIView beginAnimations:@"rotation" context:NULL];

        //旋轉時間

        [UIView setAnimationDuration:0.6];

        cell.layer.transform = CATransform3DIdentity;

        cell.alpha = 1;

        cell.layer.shadowOffset = CGSizeMake(0, 0);

        [UIView commitAnimations];

//由小到大漸變

CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DRotate(transform, 0, 0, 0, 1);//漸變
    transform = CATransform3DTranslate(transform, -200, 0, 0);//左邊水平移動
    transform = CATransform3DScale(transform, 0, 0, 0);//由小變大
    
    cell.layer.transform = transform;
    cell.layer.opacity = 0.0;
    
    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
        cell.layer.opacity = 1;
    }];