Created
August 21, 2019 17:42
-
-
Save lobrien/e19fe05dbc932ac4879ed67d48743ce9 to your computer and use it in GitHub Desktop.
Simple layout anchor example
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
faceContainingImage.Image = UIImage.FromFile("docs.jpg"); | |
//Put it on the screen | |
View.AddSubview(faceContainingImage); | |
faceContainingImage.TranslatesAutoresizingMaskIntoConstraints = false; | |
var dpConstraints = new[] | |
{ | |
faceContainingImage.LeadingAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.LeadingAnchor), | |
faceContainingImage.TrailingAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TrailingAnchor), | |
faceContainingImage.TopAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TopAnchor, 40.0f), | |
faceContainingImage.HeightAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.HeightAnchor, (nfloat) 0.5) | |
}; | |
NSLayoutConstraint.ActivateConstraints(dpConstraints); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment