Transform translation and scale of UIView.
Basic transform translation and scale of UIView.
let targetView = UIView() // Some target view
let targetFrame = contentView.convert(targetView.frame, from: targetView.superview) // If you need
let tx = targetFrame.origin.x - (frame.origin.x + (frame.size.width - targetFrame.size.width) / 2)
let ty = targetFrame.origin.y - (frame.origin.y + (frame.size.height - targetFrame.size.height) / 2)
let translation = CGAffineTransform(translationX: tx, y: ty)
let scaleValue = targetFrame.size.height / frame.size.height
let scale = CGAffineTransform(scaleX: scaleValue, y: scaleValue)
let result = scale.concatenating(translation)