Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Last active May 26, 2020 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/9f4fa27c67b0c13b48e8bb8cf66dbc78 to your computer and use it in GitHub Desktop.
Save stevencurtis/9f4fa27c67b0c13b48e8bb8cf66dbc78 to your computer and use it in GitHub Desktop.
UIImageView
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