ダブルバッファリング
UIViewのサブクラスを定義してdrawRect:で以下のコードを実行。NSTimerで定期的に再描画。
- (void)drawRect:(CGRect)rect { static int y = 0; CGContextRef c = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(c, 0, 1, 0, 1); CGContextSetLineWidth(c, 2); CGContextMoveToPoint(c, 0, y); CGContextAddLineToPoint(c, 320, y); CGContextStrokePath(c); y += 240; }
実行すると、画面中央には水平線が再描画のたびに表示非表示をくり返す。そうなるのはダブルバッファリングのためだろうか。