Skip to content

Commit

Permalink
Fixed NS/UIScreen scale compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Feb 28, 2016
1 parent a671c7a commit 2dba16f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Charts/Classes/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate
/// - returns: the bitmap that represents the chart.
public func getChartImage(transparent transparent: Bool) -> NSUIImage?
{
NSUIGraphicsBeginImageContextWithOptions(bounds.size, opaque || !transparent, NSUIMainScreen()?.nsScale ?? 1.0)
NSUIGraphicsBeginImageContextWithOptions(bounds.size, opaque || !transparent, NSUIMainScreen()?.nsuiScale ?? 1.0)

let context = NSUIGraphicsGetCurrentContext()
let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: bounds.size)
Expand Down
12 changes: 10 additions & 2 deletions Charts/Classes/Utils/ChartPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple
{
return self.gestureRecognizers
}
}
}

extension UIScreen
{
var nsuiScale: CGFloat
{
return self.scale
}
}

func NSUIGraphicsGetCurrentContext() -> CGContextRef?
{
Expand Down Expand Up @@ -427,7 +435,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple

extension NSScreen
{
var scale: CGFloat
var nsuiScale: CGFloat
{
return self.backingScaleFactor
}
Expand Down

0 comments on commit 2dba16f

Please sign in to comment.