zoukankan      html  css  js  c++  java
  • swif开发笔记12-Animations

    //cell的动画出现

     

            tableView.reloadData()

            let cells = tableView.visibleCells

            let height = tableView.bounds.size.height

            // 将所有的cell平移到屏幕底部

            for cell in cells {

                cell.transform = CGAffineTransform.init(translationX: 0, y: height)

            }

            // cell动画回到正确位置

            var index = 0

            for cell in cells {

                UIView.animate(withDuration: 1.5, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {

                    cell.transform = CGAffineTransform.init(translationX: 0, y: 0)

                }, completion: nil)

                index += 1

            }

     

    // 旋转动画

    CGAffineTransform.init(rotationAngle:CGFloat.pi)

     

    // 画圆

    func huaYuan() -> UIView {

        let circlePath = UIBezierPath.init(arcCenter: CGPoint.init(x: 100, y: 500), radius: CGFloat.init(20), startAngle: CGFloat.init(0), endAngle: CGFloat.init(CGFloat.pi.native*2), clockwise: true)

        let shapeLayer = CAShapeLayer.init()

        shapeLayer.path = circlePath.cgPath

        shapeLayer.fillColor = UIColor.red.cgColor

        shapeLayer.strokeColor = UIColor.red.cgColor

        shapeLayer.lineWidth = 3.0

        

        let view = UIView.init()

        view.layer.addSublayer(shapeLayer)

        return view

    }

    // 指定动画轨迹

            // 指定点

            var firstPoint = yuanView.center

            firstPoint.y -= 100

            var secondPoint = firstPoint

            secondPoint.x += 40

            secondPoint.y -= 125.0;

            var endPoint = firstPoint

            endPoint.x += 40

            endPoint.y += 100

            

            let path = UIBezierPath.init()

            path.move(to: self.yuanView.center)

            path.addCurve(to: endPoint, controlPoint1: firstPoint, controlPoint2: secondPoint)

            // 动画

            let anima = CAKeyframeAnimation.init(keyPath: "position")

            anima.path = path.cgPath

            anima.duration = self.duration

            self.yuanView.layer.add(anima, forKey: "animate position along path")

            self.yuanView.center = endPoint

    // 指定变大变小

            let currentFrame = self.myView.frame

            let firstFrame = currentFrame.insetBy(dx: -30, dy: -10)

            let secodeFrame = firstFrame.insetBy(dx: 50, dy: 30)

            let thirdFrame = secodeFrame.insetBy(dx: -10, dy: -20)

    // 等比例变大变小

    CGAffineTransform.init(scaleX: CGFloat.init(self.scale), y: CGFloat.init(self.scale))

    CGAffineTransform.identity// 复原frame

  • 相关阅读:
    IT民工的时间哪儿来的
    解决Office2007安装时出现错误1706的方法
    情人节特献:有心之函数必然就有分手函数
    mathematica汉化 版本二
    项目经理职责与权利
    什么是产品经理?主要职责是什么?
    调查收藏
    如何在CLI命令行下运行PHP脚本,同时向PHP脚本传递参数?
    PHP的GC垃圾收集机制
    AWStats分析Tomcat\Apache\IIS\nginx 的访问日志
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/7382453.html
Copyright © 2011-2022 走看看