Reputation: 2332
I´m new to Swift 3 and I´m trying to translate the function to 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];
}
}
}
I have made so far this but I have not bean able to translate this part:
CGAffineTransform zoom = CGAffineTransformMakeScale(self.scale, self.scale);
CGPathRef movedPath = CGPathCreateCopyByTransImformingPath([area.pathArea CGPath], &zoom);
area.pathAreaTransformed = [UIBezierPath bezierPathWithCGPath:movedPath];
I´m this:
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)
}
}
}
}
}
I´m getting this error:
Ambiguous reference to member 'copy(dashingWithPhase:lengths:transform :) '
I have found nothing on the web but this:
But I can't make it work.
Thanks in advance.
Happy coding.
Upvotes: 4
Views: 1824
Reputation: 299325
This line is incorrect:
var movedPath = CGPath.copy(using: &zoom)
.copy(using:)
is a instance method, not a class method. You meant (according to the original code):
let movedPath = area.pathArea.cgPath.copy(using: &zoom)
Upvotes: 6