• iOS上一个实用的3D动画广告视图
  • 直接上代码,学习使用,请勿喷,谢谢。。,代码已测试ke

    直接上代码,学习使用,请勿喷,谢谢。。,代码已测试可用。

    import Foundation
    import UIkit
    import QuartzCore
    
    class Animator{
         func flipHorizontalViewContorller(nextController: UIViewController!,selfViewController: UIViewController!,back:() -> Void){
            nextController.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal
            selfViewController.presentViewController(nextController, animated: true, completion:back)
        }
        
        func coverVerticalViewContorller(nextController: UIViewController!,selfViewController: UIViewController!,back:() -> Void){
            nextController.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
            selfViewController.presentViewController(nextController, animated: true, completion:back)
        }
        
        func crossDissolveViewContorller(nextController: UIViewController!,selfViewController: UIViewController!,back:() -> Void){
            nextController.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
            selfViewController.presentViewController(nextController, animated: true, completion:back)
        }
        
        func partialCurlViewContorller(nextController: UIViewController!,selfViewController: UIViewController!,back:() -> Void){
            nextController.modalTransitionStyle = UIModalTransitionStyle.PartialCurl
            selfViewController.presentViewController(nextController, animated: true, completion:back)
        }
        
        func viewMoveInFromLeft(nextView:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "moveIn"
            animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut")
            animation.subtype = "fromLeft"
            animation.fillMode = "forwards"
            nextView.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewMoveInFromRight(nextView:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "moveIn"
            animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut")
            animation.subtype = "fromRight"
            animation.fillMode = "forwards"
            nextView.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewMoveInFromTop(nextView:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "moveIn"
            animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut")
            animation.subtype = "fromTop"
            animation.fillMode = "forwards"
            nextView.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewMoveInFromBottom(nextView:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "moveIn"
            animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut")
            animation.subtype = "fromBottom"
            animation.fillMode = "forwards"
            nextView.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewFadeOut(nextView:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "fade"
            animation.timingFunction = CAMediaTimingFunction(name: "easeOut")
            animation.fillMode = "forwards"
            nextView.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewFadeIn(nextView:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "fade"
            animation.timingFunction = CAMediaTimingFunction(name: "easeIn")
            animation.fillMode = "forwards"
            nextView.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewFlipFromLeft(view:UIView!,aniTime:Float!){
            UIView.beginAnimations(nil, context: nil)
            UIView.setAnimationCurve(UIViewAnimationCurve.EaseInOut)
            UIView.setAnimationDuration(NSTimeInterval(aniTime))
            UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromLeft, forView: view, cache: false)
            UIView.commitAnimations()
        }
        
        func viewFlipFromRight(view:UIView!,aniTime:Float!){
            UIView.beginAnimations(nil, context: nil)
            UIView.setAnimationCurve(UIViewAnimationCurve.EaseInOut)
            UIView.setAnimationDuration(NSTimeInterval(aniTime))
            UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: view, cache: false)
            UIView.commitAnimations()
        }
        
        func viewCurup(view:UIView!,aniTime:Float!){
            UIView.beginAnimations(nil, context: nil)
            UIView.setAnimationCurve(UIViewAnimationCurve.EaseInOut)
            UIView.setAnimationDuration(NSTimeInterval(aniTime))
            UIView.setAnimationTransition(UIViewAnimationTransition.CurlUp, forView: view, cache: false)
            UIView.commitAnimations()
        }
        
        func viewCurdown(view:UIView!,aniTime:Float!){
            UIView.beginAnimations(nil, context: nil)
            UIView.setAnimationCurve(UIViewAnimationCurve.EaseInOut)
            UIView.setAnimationDuration(NSTimeInterval(aniTime))
            UIView.setAnimationTransition(UIViewAnimationTransition.CurlDown, forView: view, cache: false)
            UIView.commitAnimations()
        }
        
        func viewPushUp(view:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "push"
            animation.timingFunction = CAMediaTimingFunction(name: "easeOut")
            animation.fillMode = "forwards"
            animation.subtype = "fromTop"
            view.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewPushDown(view:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "push"
            animation.timingFunction = CAMediaTimingFunction(name: "easeOut")
            animation.fillMode = "forwards"
            animation.subtype = "fromBottom"
            view.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewPushLeft(view:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "push"
            animation.timingFunction = CAMediaTimingFunction(name: "easeOut")
            animation.fillMode = "forwards"
            animation.subtype = "fromLeft"
            view.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func viewPushRight(view:UIView!,aniTime:Float!,animoteKey:String!){
            var animation:CATransition = CATransition()
            animation.duration = CFTimeInterval(aniTime)
            animation.type = "push"
            animation.timingFunction = CAMediaTimingFunction(name: "easeOut")
            animation.fillMode = "forwards"
            animation.subtype = "fromRight"
            view.layer.addAnimation(animation, forKey: animoteKey)
        }
        
        func animationRotateAndScaleEffects(view:UIView!,aniTime:Float!){
            UIView.animateWithDuration(NSTimeInterval(aniTime), animations: {
                view.transform = CGAffineTransformMakeScale(0.001,0.001)
                var animation:CABasicAnimation = CABasicAnimation(keyPath: "transform")
                
                animation.toValue = NSValue(CATransform3D: CATransform3DMakeRotation(CGFloat(M_PI), 1,0,0))
                animation.duration = CFTimeInterval(aniTime)
                }, completion: {completion in
                            UIView.animateWithDuration(NSTimeInterval(aniTime), animations: {
                               view.transform = CGAffineTransformMakeScale(1,1)
                        })
                })
        }
        
    }


    展开全文
  • 今天在网到有人实现了一个旋转菜单,我用CAKeyFrameAnimation(position)和CABasicAnimation(transform.scale...实现代码:都在一个swift即可。 1.先自定义一个UIButton类,添加两个属性 import UIKit class CustomBu
  • 1.缩放 2.左右摇晃 3.翻转
  • swift 动画集合Animation 2016-05-20 17:17:04
    swift 动画集合Animation将自己平时练手的动画放在这里 ,并且附上源码 (做一个加一个吧) 后面看情况要不要单个写详细博客基础效果一 : (属性动画和transform以及view的过渡transition) 基础效果二:...
  • 原文 ...主题 Swift table of content spring介绍 简单介绍使用spring实现动画效果 spring代码拆解  demo架构核心动画实现 spring介绍 spring 是一个基于swift写的
  • RSLoadingView:3D 效果的 Loading 动画组件,采用Swift编写
  • swift3d 4.5进步了 2009-05-31 17:53:00
    swift3d 4.5进步了学了3d以后我所考虑的一点就是如何让flash和3d更紧密的结合,要考虑的首要问题就是文件的体积,网络的加载速度,再漂亮的flash动画等个10分钟,人也烦了,所以,这个基于此,有两个方法一就是用3d...
  • ARKit和SceneKit实现3D模型交互 这篇文章讲的是如何把AR模型添加到增强现实中,以及添加一些和用户的点击交互。 ARKit&SceneKit iOS 11引入了ARKit,这是一个新框架,可以让你在iPhone和iPad上轻松体验增强现实...
  • 零基础Swift实战开发从入门到精通(4大项目实战、酷跑熊猫、百度音乐、足球游戏等) 适合人群:初级 课时数量:50课时 更新程度:86% 用到技术:Swift 涉及项目:酷跑熊猫、百度音乐、足球游戏 咨询qq:...
  • 下面的一个样例是让tableView显示数据的时候具有一个很炫的3D缩放效果。 我们只需要实现tableView的willDisplayCell方法。看方法名就知道这是在Cell将要显示的时候执行的方法。 1 2 3 4 5 6 7 8 9...
  • iOS动画:3D动画(18) 2019-05-09 19:54:13
    效果看起来就像一个3D动画。现在我们来实现这种效果。 打开工程中的ContainerViewController.swift,创建3D变换函数: func menuTransform(percent: CGFloat) -> CATransform3D {//percent表示菜单显示的百分比...
  • 动画的创建首先创建一个组动画,也就是大小变化和透明度变化的动画。// 大小变化 let scaleAnimation = CAKeyframeAnimation(keyPath: "transform.scale") scaleAnimation.keyTimes = [0, 0.5, 1] ...
  • 做成动画扩散效果,这图不是动态的,是我直接截图下来的; 拿别人的代码自己删改了一些,然后加一些自己理解的注释上去,就成这样了!记录下来 1. 在图片名 那里加入一张自己文件中的图片名, 2.如果你的动图...
  • Swift 开源项目汇总 2019-09-16 16:07:05
    Swift 开源项目汇总
  • 文章转载自我的个人博客原文链接自言自语: 亿万千百十, 皆起于一资料1 —...Github上的地址点我Using Swift with Cocoa and Objective-CWWDC 2015 系统化的开发文档iOS Developer LibrarySwift 开源及跨平台开发swift
  • 全面的Swift学习资料整理 2016-12-30 17:08:14
    资料1 ---教程类 官方文档中文翻译http://wiki.jikexueyuan.com/project/swift/Github上的地址点我 Using Swift with Cocoa and Objective-C ...Swift 开源及跨平台开发swift.org 斯坦福课程Stanford Un
  • Electric Rain ZAM 3DElectric Rain ZAM 3D是一个功能齐全的3D建模软件,可轻松创建,定制和动画基于Windows Vista 应用的3D界面要素。 一旦创建三维场景,Electric Rain ZAM 3D自动生成XAML(扩展应用程序标记语言...
  • GitHub上Swift开源项目! 2017-02-04 19:10:16
    swift-open-project这里汇集了目前为止最为流行的Swift开源项目,选取SwiftGuide中的开源部分,这里将每周对项目进行总结,如果大家有推荐的可以联系thinkloki@gmail.com,或者issues,欢迎Star、Fork。感谢...
  • 分享一个自己做的3d立方体(在瑞士航空见到过类似的这种首页),还可以添加以下要素变得更加完善: 1)旋转过程中每个面的透明度可以更改 2)手势滑动结束可以添加惯性转动动画  效果如图: 直接上代码...
1 2 3 4 5 ... 20
收藏数 2,063
精华内容 825
热门标签