Deseo dibujar una línea curva hasta que haga una rotación completa y se una para formar un círculo completo, solo el contorno del círculo, no rellenado. Esto tiene que ser animado durante varios segundos.iPhone: Dibujando una línea curva hasta que se convierta en una animación circular
¿Alguien puede indicarme la dirección correcta? Ya le pedí un similar question a esto, pero lo redacté incorrectamente, por lo que a todos les costaba entender lo que quería decir y, por lo tanto, se perdió en el mar de preguntas.
Muchas Gracias por cualquier ayuda
[editar]
estoy actualmente subclasificar UIView y drawRect primordial. Encontré código para dibujar un círculo relleno, pero solo necesito el trazo.
- (void)drawRect:(CGRect)rect {
// Drawing code
CGRect allRect = self.bounds;
CGRect circleRect = CGRectInset(allRect, 2.0f, 2.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw background
CGContextSetRGBStrokeColor(context, self.strokeValueRed, self.strokeValueGreen, self.strokeValueBlue, self.strokeValueAlpha); // white
CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 0.1f); // translucent white
CGContextSetLineWidth(context, self.lineWidth);
CGContextFillEllipseInRect(context, circleRect);
CGContextStrokeEllipseInRect(context, circleRect);
// Draw progress
CGPoint center = CGPointMake(allRect.size.width/2, allRect.size.height/2);
CGFloat radius = (allRect.size.width - 4)/2;
CGFloat startAngle = - ((float)M_PI/2); // 90 degrees
CGFloat endAngle = (self.progress * 2 * (float)M_PI) + startAngle;
CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // white
CGContextMoveToPoint(context, center.x, center.y);
CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0);
CGContextClosePath(context);
CGContextFillPath(context);
}
[editar # 2]
he cambiado el código para eliminar todas las referencias de relleno pero ahora es todo lo que no dibujo :(alguna idea?
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGRect allRect = self.bounds;
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw background
CGContextSetRGBStrokeColor(context, self.strokeValueRed, self.strokeValueGreen, self.strokeValueBlue, self.strokeValueAlpha); // white
CGContextSetLineWidth(context, 5);
// Draw progress
CGPoint center = CGPointMake(allRect.size.width/2, allRect.size.height/2);
CGFloat radius = (allRect.size.width - 4)/2;
CGFloat startAngle = - ((float)M_PI/2); // 90 degrees
CGFloat endAngle = (self.progress * 2 * (float)M_PI) + startAngle;
CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0);
CGContextStrokePath(context);
}
[editar # 3] Solución
Right Me siento como un idiota derecho! El problema es que los valores de color de trazo no se inicializaron, lo que significa que la línea se estaba dibujando, pero obviamente no pudo verlo!
gracias por su ayuda! – bennythemink