Take the 2-minute tour ×

Trying to get a simple dotted line for my gridLines but, can't get it to work (is currently block solid line). Not much help on the internet for this!

   CPTMutableLineStyle *gridLineStyle = [CPTMutableLineStyle lineStyle];
        gridLineStyle.lineColor = [self axisGreyClr];
        //gridLineStyle.lineWidth = 1.0f;
        gridLineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.8f], nil];
share|improve this question

2 Answers 2

up vote 2 down vote accepted

What Eric said above ,Code to get the Dashed Line

CPTMutableLineStyle *gridLineStyle = [CPTMutableLineStyle lineStyle];

gridLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1],[NSDecimalNumber numberWithInt:2],[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:4],[NSDecimalNumber numberWithInt:5],[NSDecimalNumber numberWithInt:6],[NSDecimalNumber numberWithInt:7],[NSDecimalNumber numberWithInt:8],nil];
share|improve this answer

The dashPattern array should contain at least two values. This is just a wrapper for the CGContextSetLineDash() function. The first value is the length of a painted segment of the line and the second value is length of an unpainted segment. The pattern will repeat as needed to draw the line. You can provide more than two values to make patterns like — - — - —.

share|improve this answer

Your Answer


