CGPathCreateCopyByTransformingPath 到 Swift 3

CGPathCreateCopyByTransformingPath to Swift 3

我是 Swift 3 的新手,我正在尝试将函数转换为 Swift 3:

- (void) drawRect: (CGRect)rect
{
    if (self.editionMode == Zoom) {

        for (Area *area in self.mArrayPaths) {

            CGAffineTransform zoom = CGAffineTransformMakeScale(self.scale, self.scale);

            CGPathRef movedPath = CGPathCreateCopyByTransformingPath([area.pathArea CGPath],                                                         &zoom);
            area.pathAreaTransformed = [UIBezierPath bezierPathWithCGPath:movedPath];


            [area.fillColor setFill];
            [area.strokeColor setStroke];

            [area.pathAreaTransformed fill];
            [area.pathAreaTransformed stroke];
        }
    }
    else if (self.editionMode == MoveShapes) {

        [self.currentArea.fillColor setFill];
        [self.currentArea.pathAreaShift fill];
        [self.currentArea.pathAreaShift stroke];

        for (Area *area in self.mArrayPaths) {

            if (area == self.currentArea) {

                continue;
            }

            [area.fillColor setFill];
            [area.strokeColor setStroke];

            [area.pathArea fill];
            [area.pathArea stroke];
        }

    } else {

        [self.currentArea.fillColor setFill];
        [self.currentArea.pathArea fill];
        [self.currentArea.pathArea stroke];

        for (Area *area in self.mArrayPaths) {

            [area.fillColor setFill];
            [area.strokeColor setStroke];

            [area.pathArea fill];
            [area.pathArea stroke];
        }
    }
}

到目前为止我已经做了这个但是我无法翻译这部分:

    CGAffineTransform zoom = CGAffineTransformMakeScale(self.scale, self.scale);

    CGPathRef movedPath = CGPathCreateCopyByTransImformingPath([area.pathArea CGPath], &zoom);
    area.pathAreaTransformed = [UIBezierPath bezierPathWithCGPath:movedPath];

我是这样的:

override func draw(_ rect: CGRect) {
    if self.editionMode == EditionMode.Zoom {

        for area in self.mArrayPaths {

            if let area = area as? Area {
                var zoom: CGAffineTransform = CGAffineTransform.init(scaleX: self.scale, y: self.scale)

                var movedPath = CGPath.copy(using: &zoom)

                if let movedPath = movedPath {
                    area.pathAreaTransformed = UIBezierPath(cgPath: movedPath)
                }
            }
        }
    }
}

我收到这个错误:

Ambiguous reference to member 'copy(dashingWithPhase:lengths:transform :) '

我在网上找不到任何东西,但这个:

https://developer.apple.com/reference/coregraphics/1411161-cgpathcreatecopybytransformingpa?language=objc

但我做不到。

提前致谢。

编码愉快。

此行不正确:

var movedPath = CGPath.copy(using: &zoom)

.copy(using:) 是实例方法,不是 class 方法。你的意思是(根据原始代码):

let movedPath = area.pathArea.cgPath.copy(using: &zoom)