Spiral - Enjoy Drawing

2018-08-24  本文已影响0人  BiggerMax

Welcome to the spiral world, where you can adjust the density, color, layer of the spiral, draw the spiral that belongs to you, save it to your phone and share it with your friends.

Code:

funcplayAnimation() {

        let times = showingHistoryRecords.map { $0.duration }

        showingHistoryRecords.enumerated().forEach{ (index, item)in

            item.layers.forEach({ (layer)in

                varanimation:CABasicAnimation!

                ifitem.penStyle== .pencil{

                    layer.strokeEnd=0;

                    animation =CABasicAnimation.init(keyPath:"strokeEnd")

                }else{

                    layer.opacity=0;

                    animation =CABasicAnimation.init(keyPath:"opacity")

                }

                animation.duration= item.duration

                animation.fromValue=0;

                animation.toValue=1

                animation.beginTime=CACurrentMediaTime() + times.enumerated().reduce(0.0, { (result, arg1) ->Doublein

                    ifarg1.0>= index {

                        returnresult

                    }else{

                        returnresult + arg1.1

                    }

                });

                animation.isRemovedOnCompletion=false

                animation.fillMode=kCAFillModeForwards

                layer.add(animation, forKey:"animation");

            })

        }

    }

上一篇 下一篇

猜你喜欢

热点阅读