动画

来源:互联网 发布:无线路由器测试软件 编辑:程序博客网 时间:2024/04/26 05:42

1.爆破效果

{

    splashView = [[UIImageView alloc] initWithFrame:self.window.frame];  
    [splashView setImage:[UIImage imageNamed:@"Default.png"]];
    [self.window addSubview:splashView];
    
    CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    positionAnimation.values = [NSArray arrayWithObjects:[NSValue valueWithCGPoint:splashView.center], nil];
    positionAnimation.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithFloat:0.3], nil];
    
    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
    scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(3, 3, 1)];
    
    CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
    opacityAnimation.toValue  = [NSNumber numberWithFloat:0.0f];
    
    CAAnimationGroup *animationgroup = [CAAnimationGroup animation];
    animationgroup.delegate = self;
    animationgroup.animations = [NSArray arrayWithObjects:positionAnimation, scaleAnimation, opacityAnimation, nil];
    animationgroup.duration = 0.3f;
    animationgroup.fillMode = kCAFillModeForwards;
    
    [splashView.layer addAnimation:animationgroup forKey:@"blowup"];

}

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
    [splashView removeFromSuperview];
    [splashView release];
}

2.多桢动画

{

    UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    animatedImageView.animationImages = [NSArray arrayWithObjects:    
                                         [UIImage imageNamed:@"LauchFinish1"],
                                         [UIImage imageNamed:@"LauchFinish2"],
                                         [UIImage imageNamed:@"LauchFinish3"],
                                         [UIImage imageNamed:@"LauchFinish4"],
                                         [UIImage imageNamed:@"LauchFinish5"],
                                         [UIImage imageNamed:@"LauchFinish6"],
                                         [UIImage imageNamed:@"LauchFinish7"],
                                         [UIImage imageNamed:@"LauchFinish8"],
                                         [UIImage imageNamed:@"LauchFinish9"],
                                         [UIImage imageNamed:@"LauchFinish10"],
                                         [UIImage imageNamed:@"LauchFinish11"],
                                         [UIImage imageNamed:@"LauchFinish12"],
                                         [UIImage imageNamed:@"LauchFinish13"],
                                         [UIImage imageNamed:@"LauchFinish14"],
                                         [UIImage imageNamed:@"LauchFinish15"],
                                         [UIImage imageNamed:@"LauchFinish16"], nil];
    animatedImageView.animationDuration = 1.5f;
    animatedImageView.animationRepeatCount = 0;
    [animatedImageView startAnimating];
    [self.window addSubview: animatedImageView];
    [self performSelector:@selector(dismissAnimated) withObject:nil afterDelay:1.5];

}

3.一般动画

    [UIView animateWithDuration:kSlideSpeed animations:^{
        CGRect theFrame = self.mainViewController.view.frame;
        theFrame.origin.x = theFrame.size.width - kSlideOverlapWidth;
        self.mainViewController.view.frame = theFrame;
    } completion:^(BOOL finished) {
        [self addTapViewOverlay];
    }];