我正在使用 Core Graphics 进行绘图,我需要缩小当前上下文。我使用 CGContextScaleCTM 函数,但这使用 de origin 而不是中心。如何从中心制作比例?
问问题
1539 次
2 回答
2
缩放后,您可以使用CGContextTranslateCTM
将上下文移动到您喜欢的任何位置。
于 2012-12-15T14:27:25.293 回答
2
根据需要更改常数。
let percentScale : CGFloat = 0.8
context.translateBy(x: rect.size.width * (1.0 - percentScale) * 0.5, y: rect.size.height * (1.0 - percentScale) * 0.5)
context.scaleBy(x: percentScale, y: percentScale)
// ...draw into context
于 2019-07-01T04:33:38.517 回答