如何在iPhone SDK中进行雷达动画?

时间:2021-09-27 19:44:25

Does anyone know how to animate a radar animation like the image below? alt text http://img197.imageshack.us/img197/7124/circle0.png

有谁知道如何动画雷达动画,如下图所示? alt text http://img197.imageshack.us/img197/7124/circle0.png

With it growing outwards? I have to draw the circle using Quartz or some other way?

随着它向外发展?我必须使用Quartz或其他方式绘制圆圈?

1 个解决方案

#1


To draw a static circle in a UIView subclass:

要在UIView子类中绘制静态圆:

- (void)drawRect:(CGRect)rect
{
    CGRect rect = { 0.0f, 0.0f, 100.0f, 100.0f };
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);
    CGContextSetLineWidth(context, 2.0f);
    CGContextAddEllipseInRect(context, rect);
    CGContextStrokePath(context);
}

From there you just need to animate it with a timer, vary the size of the rect, and add more circles.

从那里你只需要用计时器设置动画,改变矩形的大小,并添加更多的圆圈。

#1


To draw a static circle in a UIView subclass:

要在UIView子类中绘制静态圆:

- (void)drawRect:(CGRect)rect
{
    CGRect rect = { 0.0f, 0.0f, 100.0f, 100.0f };
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);
    CGContextSetLineWidth(context, 2.0f);
    CGContextAddEllipseInRect(context, rect);
    CGContextStrokePath(context);
}

From there you just need to animate it with a timer, vary the size of the rect, and add more circles.

从那里你只需要用计时器设置动画,改变矩形的大小,并添加更多的圆圈。