Created
December 31, 2014 14:38
-
-
Save martinnormark/e1f57b995ffb48c4c139 to your computer and use it in GitHub Desktop.
Correctly scaling a full size background image in iOS, to seamlessly transition from launch image
This file contains hidden or 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
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.view.backgroundColor = UIColor.whiteColor() | |
let screenSize: CGRect = UIScreen.mainScreen().bounds | |
var bgImage = UIImageView(image: UIImage(named: "login-bg")) | |
bgImage.center = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2) | |
bgImage.transform = CGAffineTransformMakeScale(screenSize.width / 414, screenSize.height / 736) | |
self.view.addSubview(bgImage) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment