ios - UIImage中的图像在绘制时调整大小
问题描述
当我将图像加载到我的 UIImageView 并想在上面画画时。然后会改变图像的比例。有人可以告诉我这里出了什么问题吗?
谢谢
绘图前
当你画
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()
}
解决方案
推荐阅读
- python - How to get content length for google drive download ?
- python - 替换pytest中的测试用例继承?
- angular - Angular 6延迟加载引发错误
- networking - 如何将电脑变成本地网络设备的云服务器
- file - 用于安装程序的 Bat 文件 - 进行一次安装,等待安装完成
- react-native - react-native: LayoutAnimation 和 useNativeDriver: true for flex
- mongodb - findOneAndUpdate 不创建 ObjectId
- jquery - 未捕获的类型错误:$(...).pickadate 不是函数
- xcode - React Native / EXPO / iOS Simulator Stuck @ 'Downloading Javascript Bundle 100%'
- ruby-on-rails - Rails 应用程序连接到未知数据库?