我使用此代码在屏幕上绘制触摸路径,但随着屏幕尺寸的增加,触摸路径不稳定。任何人都可以提供一个建议吗?随着屏幕尺寸的增大,屏幕上的触摸屏路径也在缩小
路径绘制在6S
路径上绘制4S
func draw(start: CGPoint, end: CGPoint){
UIGraphicsBeginImageContext(self.subImageView.frame.size)
let context = UIGraphicsGetCurrentContext()
subImageView?.image?.drawInRect(CGRect(x: 0, y: 0, width: subImageView.frame.width, height: subImageView.frame.height))
CGContextSetLineWidth(context, 6)
CGContextBeginPath(context)
CGContextMoveToPoint(context, start.x, start.y)
CGContextAddLineToPoint(context, end.x, end.y)
CGContextSetStrokeColorWithColor(context, UIColor.redColor().CGColor)
CGContextStrokePath(context)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
subImageView.image = newImage
}
请再次添加图片请 –