iOS(iPhone,iPod,iPad)アプリの開発に関する小ネタ集です。徳島大学でアプリ開発を行っているmake.appが運営しています。make.app公式サイト http://app.ias.tokushima-u.ac.jp/

手書きメモの一部

    CGPoint currentPoint = [[touches anyObject] locationInView:self.canvasView];
    CGPoint prevPoint = [[touches anyObject] previousLocationInView:self.canvasView];
    
    UIGraphicsBeginImageContext(self.canvasView.frame.size);
    [self.canvasView.image drawInRect:CGRectMake(0, 0, self.canvasView.frame.size.width, self.canvasView.frame.size.height)];
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);  // 太さ
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);  // 線の色
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);  // 線の角を丸く
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), prevPoint.x, prevPoint.y);  // ここから
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);  // ここへ
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    
    self.canvasView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

メンバーのみ編集できます