I'm drawing with Core Graphics and I need to scale down the current context. I use the CGContextScaleCTM function but this use de origin and not the center. How can I make scale from center?
Change constant as required.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With