private void BuildView() { // create NewTargetInput = new UITextField { TranslatesAutoresizingMaskIntoConstraints = false }; CancelTargetButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false }; CancelTargetButton.SetTitle("Cancel", UIControlState.Normal); // styles NewTargetInput.Placeholder = "Give a name to the target..."; NewTargetInput.ClearButtonMode = UITextFieldViewMode.Always; NewTargetInput.BorderStyle = UITextBorderStyle.Line; NewTargetInput.ReturnKeyType = UIReturnKeyType.Done; CancelTargetButton.SetTitleColor(UIColor.Black, UIControlState.Normal); CancelTargetButton.SetTitleColor(UIColor.Gray, UIControlState.Highlighted); // hierarchy Add(NewTargetInput); Add(CancelTargetButton); // constraints TranslatesAutoresizingMaskIntoConstraints = false; NewTargetInput.AlignTopAnchor(TopAnchor, 10f); NewTargetInput.AlignLeftAnchor(LeftAnchor, 10f); NewTargetInput.AlignRightAnchor(CancelTargetButton.LeftAnchor, 20f); NewTargetInput.AlignBottomAnchor(BottomAnchor, 10f); CancelTargetButton.AlignTopAnchor(TopAnchor, 10f); CancelTargetButton.AlignRightAnchor(RightAnchor, 10f); CancelTargetButton.AlignBottomAnchor(BottomAnchor, 10f); }
private void BuildView() { // create LeftButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false }; LeftButton.SetTitle("<", UIControlState.Normal); DateLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false }; DateLabel.TextAlignment = UITextAlignment.Center; RightButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false }; RightButton.SetTitle(">", UIControlState.Normal); // styles LeftButton.SetTitleColor(UIColor.Black, UIControlState.Normal); LeftButton.SetTitleColor(UIColor.Gray, UIControlState.Highlighted); RightButton.SetTitleColor(UIColor.Black, UIControlState.Normal); RightButton.SetTitleColor(UIColor.Gray, UIControlState.Highlighted); // hierarchy Add(LeftButton); Add(DateLabel); Add(RightButton); // constraints TranslatesAutoresizingMaskIntoConstraints = false; LeftButton.AlignTopAnchor(TopAnchor, 5f); LeftButton.AlignLeftAnchor(LeftAnchor, 10f); LeftButton.AlignBottomAnchor(BottomAnchor, 5f); LeftButton.AlignWidthAnchor(80f); LeftButton.AlignHeightAnchor(50f); DateLabel.AlignTopAnchor(TopAnchor, 5f); DateLabel.AlignBottomAnchor(BottomAnchor, 5f); DateLabel.AlignLeftAnchor(LeftButton.RightAnchor, 10f); DateLabel.AlignRightAnchor(RightButton.LeftAnchor, 10f); RightButton.AlignTopAnchor(TopAnchor, 5f); RightButton.AlignRightAnchor(RightAnchor, 10f); RightButton.AlignBottomAnchor(BottomAnchor, 5f); RightButton.AlignWidthAnchor(80f); RightButton.AlignHeightAnchor(50f); }