1
Я обнаружил, что, когда я использую CGAffineTransformMakeRotation для поворота строки, линия не изменяется.Почему CGAffineTransformMakeRotation не работает в Swift?
Это мой код:
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);
}
Спасибо, я решил –