1
J'ai trouvé que lorsque j'utilise CGAffineTransformMakeRotation pour faire pivoter la ligne, la ligne n'est pas modifiée.Pourquoi CGAffineTransformMakeRotation ne fonctionne pas dans Swift?
Ceci est mon code:
func drawLine(drawObj:DrawObj) {
var context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetStrokeColorWithColor(context, drawObj.drawPara.lineColor.CGColor)
CGContextSetFillColorWithColor(context, drawObj.drawPara.fillColor.CGColor)
let originX = drawObj.left - drawObj.currentWidth/2
let originY = drawObj.top - drawObj.currentHeight/2
CGContextMoveToPoint(context, originX, originY);
let toX = originX + drawObj.currentWidth
let toY = originY + drawObj.currentHeight
CGContextAddLineToPoint(context, toX, toY);
CGContextStrokePath(context);
let roation = CGAffineTransformMakeRotation(CGFloat(Double(drawObj.angle)*M_PI/(180)))
CGContextConcatCTM(context, roation)
CGContextRestoreGState(context);
}
Merci, je l'ai résolu –