单击并拖动 CGContext 绘图以将其放置在屏幕上的任意位置
Click and drag the CGContext drawing to position it anywhere on the screen
UIGraphicsBeginImageContext(MyImage.frame.size)
let context = UIGraphicsGetCurrentContext()
tempImage.image?.draw(in: CGRect(x: 0, y: 0, width: MyImage.frame.size.width, height: MyImage.frame.size.height))
context?.move(to: startPoint)
context?.addLine(to: point)
context?.setLineCap(.round)
context?.setLineWidth(3)
context?.setStrokeColor(UIColor.blue.cgColor)
context?.setBlendMode(.normal)
context?.strokePath()
tempImage.image = UIGraphicsGetImageFromCurrentImageContext()
tempImage.alpha = 1.0
UIGraphicsEndImageContext()
我正在使用上面的代码在图像上徒手绘制。绘制图像后,可以单击绘图上的任意位置并将其移动以将其放置在屏幕上的任意位置。
检查这个库:https://github.com/luiyezheng/JLStickerTextView
我想这就是我要找的东西。
UIGraphicsBeginImageContext(MyImage.frame.size)
let context = UIGraphicsGetCurrentContext()
tempImage.image?.draw(in: CGRect(x: 0, y: 0, width: MyImage.frame.size.width, height: MyImage.frame.size.height))
context?.move(to: startPoint)
context?.addLine(to: point)
context?.setLineCap(.round)
context?.setLineWidth(3)
context?.setStrokeColor(UIColor.blue.cgColor)
context?.setBlendMode(.normal)
context?.strokePath()
tempImage.image = UIGraphicsGetImageFromCurrentImageContext()
tempImage.alpha = 1.0
UIGraphicsEndImageContext()
我正在使用上面的代码在图像上徒手绘制。绘制图像后,可以单击绘图上的任意位置并将其移动以将其放置在屏幕上的任意位置。
检查这个库:https://github.com/luiyezheng/JLStickerTextView 我想这就是我要找的东西。