drawRect を使用して図形を描画する非常に単純なプロジェクトがありますが、drawRect 関数が実際に呼び出されているとは思えません。これがコードです。(他のすべては、「シングル ビュー アプリケーション」のデフォルトです。)
-(void)drawRect:(CGRect)aRect{
NSLog(@"testing...");
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextMoveToPoint(context, 50, 50);
CGContextAddLineToPoint(context, 100, 120);
CGContextAddLineToPoint(context, 20, 100);
CGContextClosePath(context);
[[UIColor greenColor] setFill];
[[UIColor redColor] setStroke];
CGContextDrawPath(context,kCGPathFillStroke);
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setNeedsDisplay];
}
読んでくれてありがとう!