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

Commit 548e6fb

Browse files
author
Gavin Bunney
committed
Added colorReferenceLines property to alter reference line stroke color
1 parent 63a1d91 commit 548e6fb

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Classes/BEMLine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ typedef NS_ENUM(NSInteger, BEMLineAnimation) {
9090
@todo This property is non-functional at this point in time. It only serves as a marker for further implementation. */
9191
@property (assign, nonatomic) CGGradientRef gradient;
9292

93-
93+
/// The reference line color. Defaults to `color`.
94+
@property (strong, nonatomic) UIColor *refrenceLineColor;
9495

9596
//----- ALPHA -----//
9697

Classes/BEMLine.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ - (void)drawRect:(CGRect)rect {
196196

197197
if (self.enableRefrenceLines == YES) {
198198
[referenceLinesPath setLineWidth:self.lineWidth/2];
199+
200+
if (self.refrenceLineColor) {
201+
[self.refrenceLineColor set];
202+
}
203+
199204
[referenceLinesPath strokeWithBlendMode:kCGBlendModeNormal alpha:self.lineAlpha/2];
200205
}
201206
} else {
@@ -215,9 +220,15 @@ - (void)drawRect:(CGRect)rect {
215220
referenceLinesPathLayer.frame = self.bounds;
216221
referenceLinesPathLayer.path = referenceLinesPath.CGPath;
217222
referenceLinesPathLayer.opacity = self.lineAlpha/2;
218-
referenceLinesPathLayer.strokeColor = self.color.CGColor;
219223
referenceLinesPathLayer.fillColor = nil;
220224
referenceLinesPathLayer.lineWidth = self.lineWidth/2;
225+
226+
if (self.refrenceLineColor) {
227+
referenceLinesPathLayer.strokeColor = self.refrenceLineColor.CGColor;
228+
} else {
229+
referenceLinesPathLayer.strokeColor = self.color.CGColor;
230+
}
231+
221232
[self animateForLayer:referenceLinesPathLayer withAnimationType:self.animationType isAnimatingReferenceLine:YES];
222233
[self.layer addSublayer:referenceLinesPathLayer];
223234
}

Classes/BEMSimpleLineGraphView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@
216216
/// Width of the line of the graph. Default value is 1.0.
217217
@property (nonatomic) CGFloat widthLine;
218218

219+
/// Color of the reference lines of the graph. Default is same color as `colorLine`.
220+
@property (strong, nonatomic) UIColor *colorReferenceLines;
221+
219222

220223
/// The size of the circles that represent each point. Default is 10.0.
221224
@property (nonatomic) CGFloat sizePoint;

Classes/BEMSimpleLineGraphView.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ - (void)drawLine {
441441
line.enableRefrenceFrame = self.enableReferenceAxisFrame;
442442

443443
line.enableRefrenceLines = YES;
444+
line.refrenceLineColor = self.colorReferenceLines;
444445
line.arrayOfVerticalRefrenceLinePoints = self.enableReferenceXAxisLines ? xAxisLabelPoints : nil;
445446
line.arrayOfHorizontalRefrenceLinePoints = self.enableReferenceYAxisLines ? yAxisLabelPoints : nil;
446447
}

0 commit comments

Comments
 (0)