objective-c - 如何让用户在 iOS 中绘制重叠的颜色?

标签 objective-c ios xcode drawing

我正在创建一个 drawing application like this ,但我有一个问题。问题是,当我用一种颜色画一条线,然后用另一种颜色画一条线时,它会在线条相交的地方给出两种颜色的组合。

- (void)drawRect:(CGRect)rect
{

    [curImage drawAtPoint:CGPointMake(0, 0)];
    CGPoint mid1 = midPoint(previousPoint1, previousPoint2); 
    CGPoint mid2 = midPoint(currentPoint, previousPoint1);

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    [self.layer renderInContext:context];

    CGContextMoveToPoint(context, mid1.x, mid1.y);
    CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 
    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextSetLineWidth(context, self.lineWidth);
    CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);

    CGContextStrokePath(context);

    [super drawRect:rect];

    [curImage release];

}

项目的其余部分可用on GitHub .

最佳答案

关于objective-c - 如何让用户在 iOS 中绘制重叠的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11758287/

相关文章:

ios - 显示来自服务器的更新数据的 watch 套件

ios - 如何在 UIAlertviewController 中激活“确定”按钮?

objective-c - OBJ-C - 从类层次结构中获取类名

ios - 有什么我不应该保存在 NSUserDefaults 中的吗

ios - 如何删除 UITableView 中的行并更新 UITableViewCell 中的标签

iOS UIWebView 缓存问题

iOS xcode、Web 服务、NSURLConnection 第二次调用失败

ios - 快速从 userDefaults 加载到 UItextfield.text

ios - 删除 UI 导航/选项卡栏和 View 之间的细线?

ios - Objective-C简单数学问题