如何修复Xcode中的“引用'kCGLineCapRound'是一个模糊的”错误

时间:2014-01-03 16:38:14

标签: ios objective-c cocoa-touch uiimageview uiimage

这是代码,我收到的错误是:对“kCGLineCapRound”的引用含糊不清

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];

    CGPoint currentLocation = [touch locationInView:self];

    UIGraphicsBeginImageContext(self.frame.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    [self.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    CGContextSetLineCap(ctx,kCGLineCapRound);
    CGContextSetLineWidth(ctx, 5.0);
    CGContextSetRGBStrokeColor(ctx, 0.0, 0.0, 1.0, 1.0);
    CGContextBeginPath(ctx);
    CGContextMoveToPoint(ctx, location.x, location.y);
    CGContextAddLineToPoint(ctx, currentLocation.x, currentLocation.y);
    CGContextStrokePath(ctx);
    self.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    location = currentLocation;
}

我不知道如何摆脱这个错误,任何帮助表示赞赏! 提前谢谢!

1 个答案:

答案 0 :(得分:0)

我认为您需要将CoreGraphics.framework添加到项目中。

http://docs.millennialmedia.com/iOS-SDK/iOSAddingFrameworks.html