How to do a swinging door animation in iOS4+

folderView_ = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"brownPaper.jpg"]];

[self.splitViewController.view addSubview:folderView_];
float duration = 1.5f;
folderView_.hidden = NO;

if (folderView_.layer.anchorPoint.x != 0.0f) {
    folderView_.layer.anchorPoint = CGPointMake(0.0f, 0.5f);
    folderView_.center = CGPointMake(folderView_.center.x - folderView_.bounds.size.width/2.0f, folderView_.center.y);
}

folderView_.frame.size.height);

[UIView animateWithDuration:duration 
                     delay:0.0f
                   options:UIViewAnimationOptionCurveEaseInOut 
                animations:^{
                    CATransform3D endTransform = CATransform3DMakeRotation(3.141f/2.0f, 0.0f, -1.0f, 0.0f);
                    endTransform.m34 = 0.001f;
                    folderView_.layer.transform = endTransform;
                }
                completion:^(BOOL finished) {
                    if (finished) {
                        folderView_.hidden = YES;
                        [folderView_ removeFromSuperview];
                        [folderView_ release];
                        folderView_ = nil;
                    }
                }];
Posted on Aug 24
Written by Wayne Hartman