阅读背景:

问题在我的代码中使用内存管理

来源:互联网 
    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
        UITouch *touch=[touches anyObject];
        currentPoint=[touch locationInView:self.view];
        rootLayer   = [CALayer layer];
        rootLayer.frame = self.view.bounds;
        [self.view.layer addSublayer:rootLayer];
        starPath = CGPathCreateMutable();
        CGPathMoveToPoint(starPath, NULL, currentPoint.x, currentPoint.y + 15.0);
        for(int i = 1; i < 5; ++i)
        {
        CGFloat x =  15.0 * sinf(i * 4.0 * M_PI / 5.0);
        CGFloat y =  15.0 * cosf(i * 4.0 * M_PI / 5.0);
        CGPathAddLineToPoint(starPath, NULL, currentPoint.x + x, currentPoint.y + y);
        }
        CGPathCloseSubpath(starPath);
        shapeLayer = [CAShapeLayer layer];
        shapeLayer.path = starPath;
        UIColor *fillColor = [UIColor colorWithWhite:0.9 alpha:1.0];
        shapeLayer.fillColor = fillColor.CGColor; 
        [rootLayer addSublayer:shapeLayer];
    }


    - (void)dealloc {
        [imageView release];
        CGPathRelease(starPath);
        [super dealloc];
    }
    -(void)touchesMoved:(NSSet *)touches withEv



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: