Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jverkoey/314659 to your computer and use it in GitHub Desktop.
Save jverkoey/314659 to your computer and use it in GitHub Desktop.
From 10d435690793854734c1e343491d3525ecb86745 Mon Sep 17 00:00:00 2001
From: Jeff Verkoeyen <jverkoey@gmail.com>
Date: Sat, 13 Feb 2010 18:14:08 -0500
Subject: [PATCH] Older SDKs (pre 3.2) seem to flip the shadow y offset, but 3.2 doesn't.
This fixes the TTStyle for shadows on 3.2.
---
src/TTStyle.m | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/TTStyle.m b/src/TTStyle.m
index 5be3bd0..3c20acf 100644
--- a/src/TTStyle.m
+++ b/src/TTStyle.m
@@ -1190,8 +1190,16 @@ static const NSInteger kDefaultLightSource = 125;
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
+ CGSize shadowOffset;
+#ifdef __IPHONE_3_2
+ shadowOffset = CGSizeMake(_offset.width, _offset.height);
+#else
+ // On older SDKs it seems that the shadow vertical offset is upside down. Strange.
+ shadowOffset = CGSizeMake(_offset.width, -_offset.height);
+#endif
+
[context.shape addToPath:context.frame];
- CGContextSetShadowWithColor(ctx, CGSizeMake(_offset.width, -_offset.height), _blur,
+ CGContextSetShadowWithColor(ctx, shadowOffset, _blur,
_color.CGColor);
CGContextBeginTransparencyLayer(ctx, nil);
[self.next draw:context];
--
1.6.6+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment