summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm')
-rw-r--r--platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm8
1 files changed, 8 insertions, 0 deletions
diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm
index 59afe559d7..e66145aec1 100644
--- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm
+++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm
@@ -12,6 +12,11 @@
+ (instancetype)mgl_valueWithOffsetArray:(std::array<float, 2>)offsetArray
{
CGVector vector = CGVectorMake(offsetArray[0], offsetArray[1]);
+#if !TARGET_OS_IPHONE
+ // Style specification assumes an origin at the upper-left corner.
+ // macOS defines an origin at the lower-left corner.
+ vector.dy *= -1;
+#endif
return [NSValue value:&vector withObjCType:@encode(CGVector)];
}
@@ -33,6 +38,9 @@
NSAssert(strcmp(self.objCType, @encode(CGVector)) == 0, @"Value does not represent a CGVector");
CGVector vector;
[self getValue:&vector];
+#if !TARGET_OS_IPHONE
+ vector.dy *= -1;
+#endif
return {
static_cast<float>(vector.dx),
static_cast<float>(vector.dy),