views:

169

answers:

1

I'm trying to draw a custom view with a drop shadow. I'm having different results from iPhone OS 3.2. Has the coordinate system changed for CGContextSetShadowWithColor from 3.2?

Here is the code I'm using:

CGContextRef    graphicContext = UIGraphicsGetCurrentContext();

CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat values1[4] = { 0, 0, 0, 1};
CGColorRef blackColor = CGColorCreate (colorspace, values1);
CGContextSetShadowWithColor(graphicContext, CGSizeMake(0, -1), 3, blackColor);
CGColorRelease(blackColor);

CGFloat values2[4] = { .5, .5, 1, 1};
CGColorRef fillColor = CGColorCreate (colorspace, values2);
CGContextSetFillColorWithColor(graphicContext, fillColor);
CGColorRelease(fillColor);
CGContextFillRect(graphicContext,CGRectMake(40, 40, 100, 100));

Here is how it looks on 3.1 and from 3.2.

All my views using drop shadow look different depending on the version of iPhone OS. Am I missing something?

+1  A: 

This was changed in iPhoneOS 3.2, but it wasn't in the release notes. You have to check the OS Version and reverse the y-Axis of your shadow offset.

As an Apple-engineer stated in the devforums, this is not a bug, it's a change in API.

tonklon
I don't see why they changed that. They must have their reasons... Thanks for the info.
Axel