Last active
May 26, 2020 12:37
-
-
Save stevencurtis/9f4fa27c67b0c13b48e8bb8cf66dbc78 to your computer and use it in GitHub Desktop.
UIImageView
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
class ViewController: UIViewController { | |
@IBOutlet weak var manView: UIImageView! | |
var programaticView: UIImageView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.view.backgroundColor = .gray | |
programaticView = UIImageView() | |
self.view.addSubview(programaticView) | |
programaticView.translatesAutoresizingMaskIntoConstraints = false | |
programaticView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true | |
programaticView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor, constant: 100).isActive = true | |
programaticView.heightAnchor.constraint(equalToConstant: 200).isActive = true | |
programaticView.widthAnchor.constraint(equalToConstant: 300).isActive = true | |
programaticView.image = UIImage(named: "man") | |
programaticView.backgroundColor = .white | |
// programaticView.contentMode = .scaleToFill | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment