Domanda

I have this code

CGFloat dashArray[] = {5,2};
CGContextSetLineDash(context, 3, dashArray, 4);
CGMutablePathRef path = [self newArcPathAtPoint:point withRadius:radius startAngle:startAngle endAngle:endAngle];
[color setStroke];
CGContextAddPath(context, path);
CGContextStrokePath(context);
CGPathRelease(path);

It is giving me this on 'Debug':

Drawing in Debug mode

And this on 'Release':

Drawing in Release mode

And I don't know how to even start debugging this. Can anyone help me fix this or give me ideas to try debugging?

È stato utile?

Soluzione

SO I finally tracked down the problem. This line was the issue:

CGFloat dashArray[] = {5,2};
CGContextSetLineDash(context, 3, dashArray, 4);

I started getting the following error message:

CGContextSetLineDash: invalid dash array: negative lengths are not allowed.

On further investigation, turns out that I needed to fix the parameters that I was sending to CGContextSetLineDash. The following worked:

CGFloat dashArray[] = {5,2};
CGContextSetLineDash(context, 0, dashArray, 2);

The wrong code is working in debug mode though, which is what caused the confusion over what was wrong. Hope this helps someone in the future.

Altri suggerimenti

I know this is an old questions, but i had the same problem and was almost about to pull out my hair. I tried all the answers i could find on here. But the thing that worked to resolve the same issue for me was this:

  • In "Build Settings" of your project, go to Opimization level. Changing this from Fast,smallest to None for release resolved my issue.

Seems like something was happening during this phase that was affecting how dashed lines were drawn.

Hopes this helps someone else having this problem.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top