投影坐标与 iPhone OS 3.2 不同?
我正在尝试绘制带有阴影的自定义视图。我得到的结果与 iPhone OS 3.2 不同。 CGContextSetShadowWithColor 的坐标系从 3.2 开始有变化吗?
这是我正在使用的代码:
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));
我使用投影的所有视图看起来都不同,具体取决于 iPhone 操作系统的版本。我错过了什么吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这在 iPhoneOS 3.2 中发生了变化,但发行说明中没有。您必须检查操作系统版本并反转阴影偏移的 y 轴。
正如一位 Apple 工程师在 devforums 中所述,这不是一个错误,而是一个变化API。
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.