UIView 动画

//第一种动画方式

- (void) first_animations

{

    [UIView beginAnimations:nilcontext:nil]; //启动动画动作

    [UIView setAnimationRepeatCount:1];//设置是否重复播放

    [UIView setAnimationDuration:1];//设置动画持续时间

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];//动画曲线,具体的应用 ,可以经过实验检测

    [UIView setAnimationDelegate:self];//动画块的某个方法(最下方),委托到本类的实例

    [UIView setAnimationDidStopSelector:@selector(resetView)];//动画结束后去执行的方法

    

    CGAffineTransform oneTransform = CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180));//进行  CGAffineTransform 方式的动作(旋转拉伸等等)===>(对于CGAffineTransform 可以另外开辟一个关于CGAffineTransform使用详情的文章进行专门介绍 )

    

   CGAffineTransform twoTransform = CGAffineTransformTranslate(self.animatView.transform,0,-100);

   CGAffineTransform newTransform = CGAffineTransformConcat(oneTransform, twoTransform);

    [self.animatView setTransform:newTransform];

    [UIViewcommitAnimations];//有些网友说,这是动画结束.起始经过本人尝试试验.其实应该是,执行上方定义的动画块内容.

}

//第二中动画定义方式

- (void) second_animations

{

    CABasicAnimation *animation = [CABasicAnimationanimationWithKeyPath:@"opacity"];

    [animationsetDuration:1];

    [animationsetRepeatCount:0];

    [animationsetAutoreverses:YES];//自动反向动画

    [animation setFromValue:[NSNumbernumberWithFloat:1.0]];

    [animation setToValue:[NSNumbernumberWithFloat:0]];

    [animationsetDelegate:self];

    [self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];

}

- (void) third_animations

{

    [UIView beginAnimations:nilcontext:nil];

    [UIView setAnimationRepeatCount:1];

    [UIView setAnimationDuration:1];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];

    [UIViewsetAnimationDidStopSelector:@selector(animationDidStop:finished:)];

    [UIView commitAnimations];

}

- (void) fourth_animations

{

    CATransition *transition = [CATransitionanimation];

    transition.duration = 1.0f;         /*  间隔时间*/

    transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 动画的开始与结束的快慢*/

    transition.type =@"pageCurl"//@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"

    transition.subtype =kCATransitionFromRight;

    transition.removedOnCompletion =YES;

    transition.fillMode =kCAFillModeBackwards;

    transition.delegate =self;

    [self.animatView.layer addAnimation:transition forKey:nil];

}

-(void) resetView

{

    [self.animatView setTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];

   self.animatView.frame = CGRectMake(0, 0, 280, 200);

}

#pragma mark Delegate Methods

- (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {

   self.animatView.frame = CGRectMake(0, 0, 280, 200);

}

#define degreesToRadian(x) (M_PI * (x) / 180.0)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值