zoukankan      html  css  js  c++  java
  • 一些不错的动画效果---郭雪彬

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

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

    -(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];
    }
    

    待续。。。  

  • 相关阅读:
    Linux -- 如何减少IO过程中的CPU copy
    Linux -- 在多线程程序中避免False Sharing
    智能文件选择列表—— bat 批处理
    Windows NTFS 符号链接 与 Linux 软连接
    【2017.12.12】deepin安装U盘制作,支持 BIOS+UEFI,deepin_Recovery+Win PE
    Qt creator中文输入—fctix-qt5 源码编译 libfcitxplatforminputcontextplugin.so
    安装 Qt 及所需 gcc 等
    虚拟机安装 deepin Linux 注意事项
    deepin 常用设置
    VIM常用快捷键
  • 原文地址:https://www.cnblogs.com/sixindev/p/4490632.html
Copyright © 2011-2022 走看看