ios--UIView简单动画

//简单移动

imageView.transform = CGAffineTransformIdentity;

imageView.frame=CGRectMake(0, 100, 320, 320);

[UIView beginAnimations:@"clearmemory" context:imageView];

[UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(enablebutton)];

imageView.frame=CGRectMake(34, 0, 320, 320);  

[UIView commitAnimations];


//动画曲线

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

    // UIViewAnimationCurveEaseInOut,         // slow at beginning and end

    //UIViewAnimationCurveEaseIn,            // slow at beginning

    //UIViewAnimationCurveEaseOut,           // slow at end

    //UIViewAnimationCurveLinear             //恒定速度

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    imageView.frame=CGRectMake(22, 0, 320, 320);

    [UIView commitAnimations];

//反向重复 

    [UIView beginAnimations:@"animation3" context:imageView1];

    [UIView setAnimationCurve:UIViewAnimationCurveLinear];

    [UIView setAnimationDuration:1.0];

    [UIView setAnimationRepeatAutoreverses:YES];

    [UIView setAnimationRepeatCount:10];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    imageView1.alpha=0;

    [UIView commitAnimations]; 

 

 // 延时,缓入,缓出

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDelay:0.5];

    [UIView setAnimationDuration:1.5];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

    

    [UIView setAnimationRepeatAutoreverses:YES];

    [UIView setAnimationRepeatCount:2];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    imageView.frame=CGRectMake(120, 0, 200, 200);

    [UIView commitAnimations];

   

    //缓出

    [UIView beginAnimations:nilcontext:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    imageView.frame =CGRectMake(235, 144, 200 , 200);

    [UIView commitAnimations];

    //放大

    [UIView beginAnimations:nilcontext:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationCurve:UIViewAnimationCurveLinear];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    imageView.transform=CGAffineTransformMakeScale(2, 2);

    [UIView commitAnimations];

 //旋转放大这里用到179.9是因为你不管前面加-+都是逆时针

    [UIView beginAnimations:nilcontext:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationCurve:UIViewAnimationCurveLinear];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    CGAffineTransform tranform1=CGAffineTransformMakeScale(1, 1);

    CGAffineTransform tranform3=CGAffineTransformMakeTranslation(200, 200);

    CGAffineTransform tranform2=CGAffineTransformMakeRotation(179.9*M_PI/180.0);

    imageView.transform =CGAffineTransformConcat(tranform1, tranform3);

    [UIView commitAnimations];

    //平移旋转

    [UIView beginAnimations:nilcontext:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    CGAffineTransform tranform1=CGAffineTransformMakeTranslation(-200, 0);

   // CGAffineTransform tranform2= CGAffineTransformMakeRotation(179.9*M_PI/180.0);

    imageView.transform =CGAffineTransformRotate(tranform1, 359.9*M_PI/180.0);

    [UIView commitAnimations];

    //翻转

    [UIView beginAnimations:nilcontext:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRightforView:self.viewcache:YES];

    //UIViewAnimationTransitionFlipFromLeft 从左往右翻

    //UIViewAnimationTransitionFlipFromRight从右往左翻

    //UIViewAnimationTransitionCurlUp   从上往下翻

    //UIViewAnimationTransitionCurlDown 从下往上翻

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(enablebutton:)];

    imageView.hidden=YES;

    imageView1.hidden=NO;

    [UIView commitAnimations];

  //淡入淡出

CATransition *animation = [CATransition animation];

animation.duration = 0.75f; //动画时长

animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

animation.delegate = self;

animation.type = kCATransitionFade//过度效果  

//kCATransitionFade  淡入淡出

//kCATransitionMoveIn  移入移出

//kCATransitionPush  压入推出

//kCATransitionReveal  覆盖移除

animation.subtype=kCATransitionFromLeft;

//kCATransitionFromRight 从左

//kCATransitionFromLeft   从右

//kCATransitionFromTop  从上

//kCATransitionFromBottom  从下

[self.view.layer addAnimation:animation forKey:@"animation"];

imageView.hidden=YES;

imageView1.hidden=NO;



-(void)enablebutton:(id)sender

{

    imageView.transform=CGAffineTransformIdentity;

    imageView.frame=CGRectMake(0, 0, 200, 200);

    //btn.enabled=NO;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值