Last active
November 14, 2017 22:13
-
-
Save Pretz/bf6e478757a465542ce7 to your computer and use it in GitHub Desktop.
Render a view at 2x scale factor in an Xcode playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func retinaWrap(view: UIView, scaleFactor: CGFloat = 2.0) -> UIView { | |
let scaleTransform = CGAffineTransformMakeScale(scaleFactor, scaleFactor) | |
let scaledView = UIView(frame: CGRectMake(0, 0, view.bounds.width * scaleFactor, view.bounds.height * scaleFactor)) | |
view.transform = scaleTransform | |
view.center = CGPoint(x: scaledView.frame.width / 2, y: scaledView.frame.height / 2) | |
scaledView.addSubview(view) | |
return scaledView | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment