【问题标题】:Why does CGContextAddArc work on 32 bit, but not 64 bit devices?为什么 CGContextAddArc 可以在 32 位设备上工作,而不是 64 位设备?
【发布时间】:2014-03-13 21:54:56
【问题描述】:

我在层委托中有以下代码。它只是画了一个蓝色圆圈。它在 32 位 iOS 设备上完美运行,但在 64 位 iOS 设备上没有任何效果。为什么?

-(void) drawLayer:(CALayer *)layer inContext:(CGContextRef)context
{
    CGContextAddArc(context, 100., 100., 10., -M_PI, M_PI, YES);
    CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor);
    CGContextFillPath(context);
}

【问题讨论】:

    标签: ios objective-c drawing core-graphics


    【解决方案1】:

    想通了。将 M_PI 转换为浮点数解决了这个问题。这一定与 CGContextAddArc 采用 CGFloat 参数这一事实有关,并且 CGFloat 在 32 位和 64 位平台上的定义不同。在 32 位上是浮点数,在 64 位上是双精度数。

    CGContextAddArc(context, 100., 100., 10., -(float)M_PI, (float)M_PI, YES);
    

    【讨论】:

    • that 在 32 位和 64 位上是不同的?!
    • 更新了答案。真正的问题不是顺时针参数。这是一个数据类型问题。
    猜你喜欢
    • 2017-04-22
    • 1970-01-01
    • 2012-12-01
    • 2020-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    相关资源
    最近更新 更多