NSLayoutContraints
Let's have a closer look at where we are initializing our UI elements. The TranslatesAutoresizingMaskIntoConstraints
property is used to determine whether we are going to use NSLayoutConstraints
to build our user interface. When we set it to false
, it means we have to implement the layout constraints for this element.
Now we want to build the user interface using layout constraints. Let's add the following after the elements are added to mainView
:
View.AddConstraints (NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, new NSDictionary("mainView", mainView))); View.AddConstraints (NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, new NSDictionary ("mainView", mainView))); mainView.AddConstraints (NSLayoutConstraint.FromVisualFormat("V:|-80-[welcomeLabel]-[audioPlayerButton]-[exitButton]", NSLayoutFormatOptions.DirectionLeftToRight, null, new NSDictionary...