Я долго пытался с этим бороться и мне нужна помощь. Я просто хочу нарисовать 25 линий от центра моего дисплея (160 200) с разнесением 14,4 градуса. Я использовал эту строку кода в цикле for, где x - множитель 14,4 градуса -
UIImage*backgroundImage = [UIImage imageNamed:@"Primate Background Only.png"];
[backgroundImage drawInRect:CGRectMake(0, 0, 320, 480)];
// Нарисовать внешний круг
rect = CGRectMake(0.0, 35.0, 320.0, 320.0);
CGContextRef contextRef = UIGraphicsGetCurrentContext(); // Get the contextRef
CGContextSetLineWidth (contextRef, 0.5); // Set the border width
CGContextSetRGBFillColor (contextRef, (219.0f/255.0f), (219.0f/255.0f), (219.0f/255.0f), 0.05f); // Set the circle fill color to GREEN
CGContextSetRGBStrokeColor (contextRef, 0.0, 0.0, 0.0, 0.2); // Set the circle border color to BLACK
CGContextFillEllipseInRect (contextRef, rect); // Fill the circle with the fill color
CGContextStrokeEllipseInRect (contextRef, rect); // Draw the circle border
// Нарисовать внутренний круг
rect = CGRectMake(25.0, 60.0, 270.0, 270.0); // Get the contextRef
CGContextSetLineWidth (contextRef, 0.5); // Set the border width
CGContextSetRGBFillColor (contextRef, (219.0f/255.0f), (219.0f/255.0f), (219.0f/255.0f), 0.25f);
CGContextSetRGBStrokeColor (contextRef, 0.0, 0.0, 0.0, 0.2); // Set the circle border color to BLACK
CGContextFillEllipseInRect (contextRef, rect); // Fill the circle with the fill color
CGContextStrokeEllipseInRect (contextRef, rect);
// Рисуем сегменты
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0.0, 0.0);
for (x=1; x<26; x++) {
CGContextSetLineWidth (context, 0.5);
CGContextSetRGBStrokeColor (context, 0.0, 0.0, 0.0, 0.25);
CGContextMoveToPoint (context, 160, 200);
CGContextAddLineToPoint (context, (160.0 * (cos((x*14.4)*(M_PI/180)))), (160.0 * (sin((x*14.4)*(M_PI/180))))); // The angle is in degrees
CGContextAddLineToPoint (context, 200, 65);
CGContextAddLineToPoint (context, 160, 200);
CGContextStrokePath(context); // Why is this not showing both line color and infill?
CGContextSetFillColorWithColor (context, [UIColor whiteColor].CGColor);
CGContextFillPath (context);
CGContextRef context = UIGraphicsGetCurrentContext();
}
(Я намеревался опубликовать изображение здесь, но оно мне не позволит!)
Может кто-нибудь исправить мои функции триггера. Это означает рисование 25 линий по часовой стрелке с 12:00 до 24:00. Вместо этого он оттягивается назад только на 90 градусов, затем возвращается, все линии также имеют длину.
Очень благодарен
Выше приведен большой пример кода, используемого для рисования буксирных внешних кругов и внутренних сегментов по запросу. Я постараюсь загрузить изображение дальше.
![enter image description here](https://i.stack.imgur.com/udFT3.png)