• 一些不错的动画效果---郭雪彬


    一些比较实用简便的抖动和震动效果和控制器跳转渐变效果,具体什么效果自己试去,只需要调用相应方法,将你的控件传进去就可以。

       废话不多说,直接上代码:

    -(void)shakeView:(UIView*)viewToShake
    {
    CGFloat t =2.0; CGAffineTransform translateRight =CGAffineTransformTranslate(CGAffineTransformIdentity, t,0.0); CGAffineTransform translateLeft =CGAffineTransformTranslate(CGAffineTransformIdentity,-t,0.0); viewToShake.transform = translateLeft; [UIView animateWithDuration:0.07 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{ [UIView setAnimationRepeatCount:2.0]; viewToShake.transform = translateRight; } completion:^(BOOL finished){ if(finished){ [UIView animateWithDuration:0.05 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ viewToShake.transform =CGAffineTransformIdentity; } completion:NULL]; } }]; } -(void)earthquake:(UIView*)itemView { CGFloat t =2.0; CGAffineTransform leftQuake =CGAffineTransformTranslate(CGAffineTransformIdentity, t,-t); CGAffineTransform rightQuake =CGAffineTransformTranslate(CGAffineTransformIdentity,-t, t); itemView.transform = leftQuake; // starting point [UIView beginAnimations:@"earthquake" context:(__bridge void *)(itemView)]; [UIView setAnimationRepeatAutoreverses:YES];// important [UIView setAnimationRepeatCount:5]; [UIView setAnimationDuration:0.07]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(earthquakeEnded:finished:context:)]; itemView.transform = rightQuake;// end here & auto-reverse [UIView commitAnimations]; }

    //下面是视图跳转渐变效果,在手机思埠发现的,还不错,顺便分享下给大家
    //使用方法:把你初始化好的Controller传进去就可以了,方便实用。
    - (void)pushFadeViewController:(UIViewController *)viewController
    {
        CATransition *transition = [CATransition animation];
        transition.duration = 1.2f;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionFade;
    	[self.view.layer addAnimation:transition forKey:nil];
        
    	[self pushViewController:viewController animated:NO];
    }
    
    
    
    - (void)fadePopViewController
    {
    	CATransition *transition = [CATransition animation];
        transition.duration = 1.2f;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionFade;
    	[self.view.layer addAnimation:transition forKey:nil];
    	[self popViewControllerAnimated:NO];
    }
    

    待续。。。  

  • 相关阅读:
    C#数据库数据导出Excel通用方法
    统计数据库大小的方法
    ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例上[转]
    ASP.NET数据库备份[转]
    XDocument读取xml的所有元素以及XPath语法[转]
    Datastage客户端安装 记录
    依赖注入控制反转 (摘抄记录)
    管道处理模型四——MVC原理(摘抄cainong2005博客)
    管道处理模型三(摘抄cainong2005博客)
    管道处理模型二(摘抄cainong2005博客)
  • 原文地址:https://www.cnblogs.com/sixindev/p/4490632.html
Copyright © 2020-2023  润新知