小编B2G*_*h T的帖子

通过 Coregraphic 画线:renderInContext 崩溃

我正在使用 CoreGraphics 画一条线。我刚刚更新了 Xcode 10 和 iOS 12。在 iOS 12 中,我的应用程序崩溃了。尽管如此,它在 iOS 11.4.1 和之前的版本中仍然运行良好。我无法解决这个问题。请在下面找到我的代码

-(void)drawRect:(CGRect)rect
{
    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);

    CGContextSetShadow(context, CGSizeMake(-16.00, -5.0f), 5.0f);

    CGContextStrokePath(context);

    [super drawRect:rect];
    [curImage release];
} 
Run Code Online (Sandbox Code Playgroud)

下面是touchesMoved方法。

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

    UITouch *touch  = [touches anyObject];

    previousPoint2  = previousPoint1;
    previousPoint1  = [touch previousLocationInView:self];
    currentPoint    = [touch locationInView:self]; …
Run Code Online (Sandbox Code Playgroud)

iphone core-graphics objective-c ios12 xcode10

5
推荐指数
1
解决办法
473
查看次数

标签 统计

core-graphics ×1

ios12 ×1

iphone ×1

objective-c ×1

xcode10 ×1