Spiral - Enjoy Drawing

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");

            })

        }

    }

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容