diff --git a/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift b/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift index efc584b8..74048e6a 100644 --- a/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift +++ b/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift @@ -107,6 +107,7 @@ func addShapeAnimation(_ animation: BasicAnimation, sceneLayer: CALayer, animati layer.lineCap = MCAShapeLayerLineCap.mapToGraphics(model: stroke.cap) layer.lineJoin = MCAShapeLayerLineJoin.mapToGraphics(model: stroke.join) layer.lineDashPattern = stroke.dashes.map { NSNumber(value: $0) } + layer.lineDashPhase = CGFloat(stroke.offset) } else if shape.fill == nil { layer.strokeColor = MColor.black.cgColor layer.lineWidth = 1.0 @@ -201,6 +202,16 @@ fileprivate func generateShapeAnimation(from: Shape, to: Shape, duration: Double group.animations?.append(dashPatternAnimation) } + + // Dash offset + if fromStroke.offset != toStroke.offset{ + let dashOffsetAnimation = CABasicAnimation(keyPath: "lineDashPhase") + dashOffsetAnimation.fromValue = fromStroke.offset + dashOffsetAnimation.toValue = toStroke.offset + dashOffsetAnimation.duration = duration + + group.animations?.append(dashOffsetAnimation) + } // Group group.duration = duration