예제 #1
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = UIColor.White
            };

            _outerStackView = new UIStackView();
            _outerStackView.TranslatesAutoresizingMaskIntoConstraints = false;
            _outerStackView.Axis         = UILayoutConstraintAxis.Vertical;
            _outerStackView.Distribution = UIStackViewDistribution.FillEqually;

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _transformToolsView = new UIStackView();
            _transformToolsView.TranslatesAutoresizingMaskIntoConstraints = false;
            _transformToolsView.Axis    = UILayoutConstraintAxis.Vertical;
            _transformToolsView.Spacing = 8;
            _transformToolsView.LayoutMarginsRelativeArrangement = true;
            _transformToolsView.LayoutMargins = new UIEdgeInsets(8, 8, 8, 8);

            _inWkidLabel = new UILabel();
            _inWkidLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            _outWkidLabel = new UILabel();
            _outWkidLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            UIStackView labelsRow = new UIStackView(new[] { _inWkidLabel, _outWkidLabel });

            labelsRow.TranslatesAutoresizingMaskIntoConstraints = false;
            labelsRow.Axis         = UILayoutConstraintAxis.Horizontal;
            labelsRow.Distribution = UIStackViewDistribution.FillEqually;
            _transformToolsView.AddArrangedSubview(labelsRow);

            _useExtentSwitch = new UISwitch();
            _useExtentSwitch.TranslatesAutoresizingMaskIntoConstraints = false;
            UILabel useExtentSwitchLabel = new UILabel();

            useExtentSwitchLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            useExtentSwitchLabel.Text = "Use extent";

            UIStackView switchRow = new UIStackView(new UIView[] { _useExtentSwitch, useExtentSwitchLabel });

            switchRow.TranslatesAutoresizingMaskIntoConstraints = false;
            switchRow.Axis    = UILayoutConstraintAxis.Horizontal;
            switchRow.Spacing = 8;
            _transformToolsView.AddArrangedSubview(switchRow);

            _transformationsPicker = new UIPickerView();
            _transformationsPicker.TranslatesAutoresizingMaskIntoConstraints = false;
            _transformationsPicker.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultLow, UILayoutConstraintAxis.Vertical);
            _transformToolsView.AddArrangedSubview(_transformationsPicker);

            _messagesTextView = new UITextView();
            _messagesTextView.TranslatesAutoresizingMaskIntoConstraints = false;
            _messagesTextView.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Vertical);
            _messagesTextView.ScrollEnabled = false;
            _transformToolsView.AddArrangedSubview(_messagesTextView);

            _outerStackView.AddArrangedSubview(_myMapView);
            _outerStackView.AddArrangedSubview(_transformToolsView);

            // Add the views.
            View.AddSubviews(_outerStackView);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _outerStackView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _outerStackView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor),
                _outerStackView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor),
                _outerStackView.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor)
            });
        }