Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 76c5f9f

Browse files
author
Gavin Bunney
committed
Altered draw order of graph to ensure reference lines are behind the graph line
1 parent 548e6fb commit 76c5f9f

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

Classes/BEMLine.m

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,32 +189,23 @@ - (void)drawRect:(CGRect)rect {
189189
// ----- Animate Drawing -----//
190190
// ---------------------------//
191191
if (self.animationTime == 0) {
192-
[self.color set];
193-
194-
[line setLineWidth:self.lineWidth];
195-
[line strokeWithBlendMode:kCGBlendModeNormal alpha:self.lineAlpha];
196-
197192
if (self.enableRefrenceLines == YES) {
198193
[referenceLinesPath setLineWidth:self.lineWidth/2];
199194

200195
if (self.refrenceLineColor) {
201196
[self.refrenceLineColor set];
197+
} else {
198+
[self.color set];
202199
}
203200

204201
[referenceLinesPath strokeWithBlendMode:kCGBlendModeNormal alpha:self.lineAlpha/2];
205202
}
206-
} else {
207-
CAShapeLayer *pathLayer = [CAShapeLayer layer];
208-
pathLayer.frame = self.bounds;
209-
pathLayer.path = line.CGPath;
210-
pathLayer.strokeColor = self.color.CGColor;
211-
pathLayer.fillColor = nil;
212-
pathLayer.lineWidth = self.lineWidth;
213-
pathLayer.lineJoin = kCALineJoinBevel;
214-
pathLayer.lineCap = kCALineCapRound;
215-
[self animateForLayer:pathLayer withAnimationType:self.animationType isAnimatingReferenceLine:NO];
216-
[self.layer addSublayer:pathLayer];
217203

204+
[self.color set];
205+
[line setLineWidth:self.lineWidth];
206+
[line strokeWithBlendMode:kCGBlendModeNormal alpha:self.lineAlpha];
207+
208+
} else {
218209
if (self.enableRefrenceLines == YES) {
219210
CAShapeLayer *referenceLinesPathLayer = [CAShapeLayer layer];
220211
referenceLinesPathLayer.frame = self.bounds;
@@ -232,6 +223,17 @@ - (void)drawRect:(CGRect)rect {
232223
[self animateForLayer:referenceLinesPathLayer withAnimationType:self.animationType isAnimatingReferenceLine:YES];
233224
[self.layer addSublayer:referenceLinesPathLayer];
234225
}
226+
227+
CAShapeLayer *pathLayer = [CAShapeLayer layer];
228+
pathLayer.frame = self.bounds;
229+
pathLayer.path = line.CGPath;
230+
pathLayer.strokeColor = self.color.CGColor;
231+
pathLayer.fillColor = nil;
232+
pathLayer.lineWidth = self.lineWidth;
233+
pathLayer.lineJoin = kCALineJoinBevel;
234+
pathLayer.lineCap = kCALineCapRound;
235+
[self animateForLayer:pathLayer withAnimationType:self.animationType isAnimatingReferenceLine:NO];
236+
[self.layer addSublayer:pathLayer];
235237
}
236238
}
237239

0 commit comments

Comments
 (0)