UIImage中的图像在绘制时会调整大小

时间:2018-10-02 09:50:20

标签: ios swift uiimageview uiimage

当我将图像加载到UIImageView并想在其上绘制时。然后将改变图像的比例。有人可以告诉我这是怎么回事吗?

谢谢

绘图之前

Before drawing

绘图时

When you drawing

func drawLines(fromPoint:CGPoint,toPoint:CGPoint) {
    UIGraphicsBeginImageContext(self.view.frame.size)
    imageView.image?.draw(in: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height))

    let context = UIGraphicsGetCurrentContext()

    context?.move(to: CGPoint(x: fromPoint.x, y: fromPoint.y))
    context?.addLine(to: CGPoint(x: toPoint.x, y: toPoint.y))

    context?.setBlendMode(CGBlendMode.normal)
    context?.setLineCap(CGLineCap.round)
    context?.setLineWidth(brushSize)
    context?.setStrokeColor(UIColor(red: red, green: green, blue: blue, alpha: opacityValue).cgColor)

    context?.strokePath()

    imageView.image = UIGraphicsGetImageFromCurrentImageContext()

    UIGraphicsEndImageContext()
}

0 个答案:

没有答案