小编pra*_*rni的帖子

使用CGContextRef绘图

我正在尝试创建一个我可以编写的应用程序.我通过使用CGContextRef取得了进展.我写了以下代码.

previousPoint2 = previousPoint1;
previousPoint1 = [touch previousLocationInView:m_secondaryDrawingImgeView];
currentPoint = [touch locationInView:m_secondaryDrawingImgeView];
// calculate mid point
CGPoint mid1 = [self midPoint:previousPoint1 :previousPoint2]; 
CGPoint mid2 =[self midPoint:currentPoint :previousPoint1];
UIGraphicsBeginImageContext(m_secondaryDrawingImgeView.frame.size);
[m_secondaryDrawingImgeView.image drawInRect:
               CGRectMake(0, 0, m_secondaryDrawingImgeView.frame.size.width,
                               m_secondaryDrawingImgeView.frame.size.height)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context, mid1.x, mid1.y);
// Use QuadCurve is the key
CGContextAddQuadCurveToPoint(context,
        previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 
// NSMutableArray *arr = [NSMutableArray arrayWithObjects:mid1, nil]
//  NSLog(@"%@",color);
CGContextSetStrokeColorWithColor(context, color.CGColor);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context,m_width);
CGContextStrokePath(context);
m_secondaryDrawingImgeView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

当我将不透明度设置为我的颜色时,它会显示在线的点,我想删除它.

这是我正在进行的正确道路吗?有什么方法可以删除这些点吗?

附加图像以获得更清晰.编写此代码后发生的事情是image-1,我想要的是image-2

在此输入图像描述 在此输入图像描述

iphone objective-c ios5

4
推荐指数
1
解决办法
3815
查看次数

标签 统计

ios5 ×1

iphone ×1

objective-c ×1