From 2a8a01f8b2d54780cf46389a78de388f46f955e6 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Dupas Date: Mon, 3 Dec 2018 16:43:52 +0100 Subject: [PATCH] Switch from dark color to labelColor to fix darkmode issues. --- Source/Charts/Charts/ChartViewBase.swift | 2 +- Source/Charts/Components/AxisBase.swift | 2 +- Source/Charts/Components/ChartLimitLine.swift | 2 +- Source/Charts/Components/Description.swift | 2 +- Source/Charts/Components/Legend.swift | 2 +- Source/Charts/Data/Implementations/ChartBaseDataSet.swift | 4 ++-- Source/Charts/Utils/Platform.swift | 8 ++++++++ 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 2ab5a6802e..6a3dcb5a16 100644 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -88,7 +88,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate @objc open var noDataFont: NSUIFont! = NSUIFont(name: "HelveticaNeue", size: 12.0) /// color of the no data text - @objc open var noDataTextColor: NSUIColor = NSUIColor.black + @objc open var noDataTextColor: NSUIColor = NSUIColor.labelColor /// alignment of the no data text open var noDataTextAlignment: NSTextAlignment = .left diff --git a/Source/Charts/Components/AxisBase.swift b/Source/Charts/Components/AxisBase.swift index 334eaf7f24..987c4d12df 100644 --- a/Source/Charts/Components/AxisBase.swift +++ b/Source/Charts/Components/AxisBase.swift @@ -25,7 +25,7 @@ open class AxisBase: ComponentBase private var _axisValueFormatter: IAxisValueFormatter? @objc open var labelFont = NSUIFont.systemFont(ofSize: 10.0) - @objc open var labelTextColor = NSUIColor.black + @objc open var labelTextColor = NSUIColor.labelColor @objc open var axisLineColor = NSUIColor.gray @objc open var axisLineWidth = CGFloat(0.5) diff --git a/Source/Charts/Components/ChartLimitLine.swift b/Source/Charts/Components/ChartLimitLine.swift index e6682e3a33..b5d21f76ab 100644 --- a/Source/Charts/Components/ChartLimitLine.swift +++ b/Source/Charts/Components/ChartLimitLine.swift @@ -34,7 +34,7 @@ open class ChartLimitLine: ComponentBase @objc open var lineDashPhase = CGFloat(0.0) @objc open var lineDashLengths: [CGFloat]? - @objc open var valueTextColor = NSUIColor.black + @objc open var valueTextColor = NSUIColor.labelColor @objc open var valueFont = NSUIFont.systemFont(ofSize: 13.0) @objc open var drawLabelEnabled = true diff --git a/Source/Charts/Components/Description.swift b/Source/Charts/Components/Description.swift index a063499e4f..34d7d30084 100644 --- a/Source/Charts/Components/Description.swift +++ b/Source/Charts/Components/Description.swift @@ -46,5 +46,5 @@ open class Description: ComponentBase @objc open var font: NSUIFont /// Text color used for drawing the description text - @objc open var textColor = NSUIColor.black + @objc open var textColor = NSUIColor.labelColor } diff --git a/Source/Charts/Components/Legend.swift b/Source/Charts/Components/Legend.swift index 6386fe327d..b5286999fc 100644 --- a/Source/Charts/Components/Legend.swift +++ b/Source/Charts/Components/Legend.swift @@ -102,7 +102,7 @@ open class Legend: ComponentBase @objc open var direction: Direction = Direction.leftToRight @objc open var font: NSUIFont = NSUIFont.systemFont(ofSize: 10.0) - @objc open var textColor = NSUIColor.black + @objc open var textColor = NSUIColor.labelColor /// The form/shape of the legend forms @objc open var form = Form.square diff --git a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift index 003438f206..1c406da523 100644 --- a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift +++ b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift @@ -21,7 +21,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying // default color colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - valueColors.append(NSUIColor.black) + valueColors.append(NSUIColor.labelColor) } @objc public init(label: String?) @@ -30,7 +30,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying // default color colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - valueColors.append(NSUIColor.black) + valueColors.append(NSUIColor.labelColor) self.label = label } diff --git a/Source/Charts/Utils/Platform.swift b/Source/Charts/Utils/Platform.swift index eef134687f..d755b86d43 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -139,6 +139,14 @@ public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State } } + extension UIColor + { + static var labelColor : UIColor + { + return UIColor.black + } + } + extension UIView { @objc final var nsuiGestureRecognizers: [NSUIGestureRecognizer]?