CGContextAddEllipseInRect( 《CGContextRef》,《CGRect》);
CGContextAddLines(《CGContextRef》,《CGPoint配列》,《ポイント数》);
CGContextMoveToPoint(《CGContextRef》, 横位置 , 縦位置 );これで、描画を開始する位置まで描画地点が移動しました。後は、そこからもう1つの点まで線を追加する関数を呼び出します。これも、次の位置を引数で指定します。――これを呼び出すと、線が追加されると同時に、描画地点は指定した位置まで変更されます。つまり、続けて何度も呼び出していくことで、連続して線を描けるわけですね。
CGContextMoveToPoint(《CGContextRef》, 横位置 , 縦位置 );
CGContextMoveToPoint(《CGContextRef》, 横位置 , 縦位置 );これは既に説明済みですね。続いて、そこから次の点まで曲線を描くための図形を追加します。これは、現在の点から描画するための1つ目のコントロールポイント、次の位置までの描画を行うための2つ目のコントロールポイント、そして次の位置、という3つの位置の情報を引数に用意します。
CGContextAddCurveToPoint(《CGContextRef》, 横位置c1 , 縦位置c1 ,
横位置c2 , 縦位置c2 , 横位置 , 縦位置 );
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※MySampleView.mのメソッド - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(context, 1.0, 0.5, 0.0, 1.0); CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.5, 1.0); CGContextSetLineWidth(context, 10.0); CGRect r1 = CGRectMake(20.0 , 20.0, 100.0, 100.0); CGContextAddEllipseInRect(context,r1); CGContextFillPath(context); CGContextMoveToPoint(context, 50, 100); CGContextAddLineToPoint(context, 150, 100); CGContextAddLineToPoint(context, 50, 200); CGContextAddLineToPoint(context, 150, 200); CGContextStrokePath(context); CGContextMoveToPoint(context,50, 250); CGContextAddCurveToPoint(context, 100, 250, 100, 200, 150, 250); CGContextAddCurveToPoint(context, 200, 350, 50, 250, 50, 350); CGContextStrokePath(context); }
<< 前へ |