多くのパスを描画するたびに、ビューを複数回再描画する必要があります。これを達成するには、何らかの種類のタイマーを使用し、描画するパスを追跡する方法が必要です。
インスタンス変数を使用し、別のパスが描画されるたびにインクリメントするパスを追跡するには、-drawRect:
でその変数の値をチェックし、適切なパス数を描画します。
次に、ivarを更新してビューを再描画するメソッドを実装します。 、限り色が行くよう
- (void)drawRect:(CGRect)rect
{
NSInteger i = 0;
for (i = 0; i < pathsDrawn; i++)
{
UIBezierPath * path = [myArrayOfBezierPaths objectAtIndex:i];
path.lineWidth=3;
[path stroke];
}
}
あなたはパスを作成しているので、あなたは彼らが何色にすることができます:あなたの描画方法は、次のようになります
//assume pathsToDraw is an NSInteger ivar
//and that myArrayOfBezierPaths is an NSArray ivar
//containing UIBezierPath objects
- (void)startDrawingPaths
{
//draw the first path
pathsToDraw = 1;
[view setNeedsDisplay];
//schedule redraws once per second
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateView:) userInfo:nil repeats:YES];
}
- (void)updateView:(NSTimer*)timer
{
//increment the path counter
pathsDrawn++;
//tell the view to update
[view setNeedsDisplay];
//if we've drawn all our paths, stop the timer
if(pathsDrawn >= [myArrayOfBezierPaths count])
{
[timer invalidate];
}
}
:ここでは非常に単純化したバージョンですあなたは好きです。