¿Cómo mostrar texto en un pie de gráfico?

He creado un PieChart usando el siguiente código. Aquí, he tomado la suma dex yy como 100% para mostrar lax% como color rojo yy% Como color verde en pieChart.

En el color rojo quiero mostrar la exactax% (Ejemplo45% (o)55%) y en el color verde quiero mostrar la exactay% (Ejemplo55% (o)45%).

En mi solicitud elX yY Los valores son variables. Esos valores cambian cada vez que ejecuto mi aplicación. Quiero mostrar el gráfico circular con los colores verde y rojo con el porcentaje en esas regiones. ¿Cómo puedo hacer cuadros para mostrar los porcentajes en esas regiones?

archivo .m

<code>- (void)drawRect:(CGRect)rect
{
// Drawing code

 int x = 25;
 int y = 42;

 float sum = x + y;
 float mult = (360/sum);

 float startDeg = 0;
 float endDeg = 0;

 int x = 74;
 int y = 60;
 int r = 60;

 CGContextRef ctx = UIGraphicsGetCurrentContext();
 CGContextSetRGBStrokeColor(ctx, 1.0, 1.0, 1.0, 1.0);
 CGContextSetLineWidth(ctx, 2.0);

 startDeg = 0;
 endDeg = (x * mult);
 if(startDeg != endDeg)
 {
 CGContextSetRGBFillColor(ctx, 0.0, 0.8, 0.0, 1.0);
 CGContextMoveToPoint(ctx, x, y);
 CGContextAddArc(ctx, x, y, r, (startDeg)*M_PI/180.0, (endDeg)*M_PI/180.0, 0);
 CGContextClosePath(ctx);
 CGContextFillPath(ctx);
 }

 startDeg = endDeg;
 endDeg = endDeg + (y * mult);
 if(startDeg != endDeg)
 {
 CGContextSetRGBFillColor(ctx, 0.8, 0.0, 0.0, 1.0);
 CGContextMoveToPoint(ctx, x, y);
 CGContextAddArc(ctx, x, y, r, (startDeg)*M_PI/180.0, (endDeg)*M_PI/180.0, 0);
 CGContextClosePath(ctx);
 CGContextFillPath(ctx);
 }
}
</code>

Respuestas a la pregunta(1)

Su respuesta a la pregunta