Domanda

i have the following code in a layer delegate. it simply draws a blue circle. it works perfectly on 32 bit iOS devices, but draws nothing on 64 bit iOS devices. why?

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

Soluzione

figured it out. casting M_PI to a float solved the problem. this must have something to do with the fact that CGContextAddArc takes CGFloat arguments, and CGFloat is defined differently on 32 bit versus 64 bit platforms. on 32 bit, it's a float, on 64 bit it's a double.

CGContextAddArc(context, 100., 100., 10., -(float)M_PI, (float)M_PI, YES);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top