How to make equal space between texts in a circular menu?

I create a circular slider menu, I use coregraphics to draw a control user interface. Here I am trying to draw words around the circumference of a circle. But I can’t make the spaces the same.

Here is my code and output. Please help me give equal spaces between each word.

In drawRect

float angleStep = 2 * M_PI / [menuArray count]; float angle = degreesToRadians(90); textRadius = textRadius - 12; for (NSString* text in`enter code here` titleArray) { [self drawStringAtContext:ctx string:text atAngle:angle withRadius:textRadius]; angle -= angleStep; } 

//////////

 - (void) drawStringAtContext:(CGContextRef) context string:(NSString*) text atAngle:(float)angle withRadius:(float) radis { CGSize textSize = [text sizeWithFont:[UIFont systemFontOfSize:11.0]]; float perimeter = 2 * M_PI * radis; float textAngle = textSize.width / perimeter * 2 * M_PI; angle += textAngle / 2; for (int index = 0; index < [text length]; index++) { NSRange range = {index, 1}; NSString* letter = [text substringWithRange:range]; char* c = (char*)[letter cStringUsingEncoding:NSASCIIStringEncoding]; CGSize charSize = [letter sizeWithFont:[UIFont systemFontOfSize:11.0]]; float x = radis * cos(angle); float y = radis * sin(angle); float letterAngle = (charSize.width / perimeter * -2 * M_PI); CGContextSaveGState(context); CGContextTranslateCTM(context, x, y); CGContextRotateCTM(context, (angle - 0.5 * M_PI)); CGContextShowTextAtPoint(context, 0, 0, c, strlen(c)); CGContextRestoreGState(context); angle += letterAngle; } } 

Exit

enter image description here

0
ios objective-c iphone core-graphics custom-component
Apr 23 '15 at 9:50
source share

No one has answered this question yet.

See similar questions:

53
Curve text on an existing circle

or similar:

1665
How can I make UITextField move up when there is a keyboard - when editing starts?
957
How to change text color of status bar in iOS
246
Scrolling a UITableView when selecting a text field
233
How to get the device and device model on iOS?
161
How to add spacing between UITableViewCell
139
Reducing the space between sections of a UITableView
98
How to make display text in UILabel?
21
Equal width and equal distance between buttons in autorun
0
How to give equal spacing between letters of a word for placeholder text in iOS



All Articles