IOS开发7-弹出框实现 官方UIAlertView的动画

头文件记得导入#import <QuartzCore/QuartzCore.h>,及加入framework

+(void)exChangeOut:(UIView *)changeOutView dur:(CFTimeInterval)dur{

    CAKeyframeAnimation * animation;
    animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

    animation.duration = dur;

    //animation.delegate = self;

    animation.removedOnCompletion = NO;

    animation.fillMode = kCAFillModeForwards; 

    NSMutableArray *values = [NSMutableArray array];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];

    animation.values = values;

    animation.timingFunction = [CAMediaTimingFunction functionWithName: @"easeInEaseOut"];

    [changeOutView.layer addAnimation:animation forKey:nil];

}

其中changeOutView 即为要实现动画的那个view,dur即为动画的时间,调用的时候传入这2个参数即可;

你可能感兴趣的:(IOS开发-弹出框实现)