public override void ViewDidLoad() { base.ViewDidLoad(); // https://developer.xamarin.com/Recipes/ios/Content_Controls/Tab_Bar/Create_a_Tab_Bar/ _tabBarItemCalendar = new UITabBarItem("Calendar", UIImage.FromBundle("TabCalendar"), UIImage.FromBundle("TabCalendarSelected")); _tabBarItemAgenda = new UITabBarItem("Agenda", UIImage.FromBundle("TabAgenda"), UIImage.FromBundle("TabAgendaSelected")); _tabBarItemSchedule = new UITabBarItem("Schedule", UIImage.FromBundle("TabSchedule"), UIImage.FromBundle("TabScheduleSelected")); _tabBarItemClasses = new UITabBarItem("Classes", UIImage.FromBundle("TabClasses"), UIImage.FromBundle("TabClassesSelected")); _tabBarItemMore = new UITabBarItem("More", UIImage.FromBundle("TabMore"), UIImage.FromBundle("TabMoreSelected")); _tabBar = new UITabBar() { TranslatesAutoresizingMaskIntoConstraints = false, Items = new UITabBarItem[] { _tabBarItemCalendar, _tabBarItemAgenda, _tabBarItemSchedule, _tabBarItemClasses, _tabBarItemMore }, //BarTintColor = ColorResources.PowerPlannerBlueChromeColor, //UnselectedItemTintColor = UIColor.White, //SelectedImageTintColor = UIColor.White SelectedImageTintColor = ColorResources.PowerPlannerAccentBlue }; _tabBar.ItemSelected += new WeakEventHandler <UITabBarItemEventArgs>(_tabBar_ItemSelected).Handler; // Have to wrap tab bar in a view as per this: https://novemberfive.co/blog/apple-september-event-iphonex-apps/ // Then that fixes the items getting squished on iPhone X var tabBarContainer = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; tabBarContainer.Add(_tabBar); _tabBar.StretchWidth(tabBarContainer); _tabBar.StretchHeight(tabBarContainer); base.Add(tabBarContainer); tabBarContainer.StretchWidth(base.View); if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { tabBarContainer.BottomAnchor.ConstraintEqualTo(this.View.SafeAreaLayoutGuide.BottomAnchor) }); // We also add a bottom blur in the safe area, otherwise there's a blank white gap on iPhone X _bottomGlass = new BareUIBlurView() { TranslatesAutoresizingMaskIntoConstraints = false }; base.Add(_bottomGlass); _bottomGlass.StretchWidth(this.View); _bottomGlass.PinToBottom(this.View); NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { _bottomGlass.TopAnchor.ConstraintEqualTo(this.View.SafeAreaLayoutGuide.BottomAnchor) }); } else { NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { tabBarContainer.BottomAnchor.ConstraintEqualTo(this.BottomLayoutGuide.GetBottomAnchor()) }); } }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; UIView formContainer = new UIView { BackgroundColor = UIColor.FromWhiteAlpha(1f, .8f) }; formContainer.TranslatesAutoresizingMaskIntoConstraints = false; _searchBox = new UITextField(); _searchBox.TranslatesAutoresizingMaskIntoConstraints = false; _searchBox.Text = "Coffee"; _searchBox.BorderStyle = UITextBorderStyle.RoundedRect; _searchBox.LeftView = new UIView(new CGRect(0, 0, 5, 20)); _searchBox.LeftViewMode = UITextFieldViewMode.Always; // Allow pressing 'return' to dismiss the keyboard. _searchBox.ShouldReturn += textField => { textField.ResignFirstResponder(); return(true); }; _locationBox = new UITextField(); _locationBox.TranslatesAutoresizingMaskIntoConstraints = false; _locationBox.Text = "Current location"; _locationBox.BorderStyle = UITextBorderStyle.RoundedRect; _locationBox.LeftView = new UIView(new CGRect(0, 0, 5, 20)); _locationBox.LeftViewMode = UITextFieldViewMode.Always; // Allow pressing 'return' to dismiss the keyboard. _locationBox.ShouldReturn += textField => { textField.ResignFirstResponder(); return(true); }; _searchButton = new UIButton(UIButtonType.RoundedRect); _searchButton.BackgroundColor = UIColor.White; _searchButton.TranslatesAutoresizingMaskIntoConstraints = false; _searchButton.SetTitle("Search all", UIControlState.Normal); _searchButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled); _searchButton.SetTitleColor(View.TintColor, UIControlState.Normal); _searchButton.Layer.CornerRadius = 5; _searchButton.Layer.BorderColor = View.TintColor.CGColor; _searchButton.Layer.BorderWidth = 1; _searchInViewButton = new UIButton(UIButtonType.RoundedRect); _searchInViewButton.BackgroundColor = UIColor.White; _searchInViewButton.TranslatesAutoresizingMaskIntoConstraints = false; _searchInViewButton.SetTitle("Search in view", UIControlState.Normal); _searchInViewButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled); _searchInViewButton.SetTitleColor(View.TintColor, UIControlState.Normal); _searchInViewButton.Layer.CornerRadius = 5; _searchInViewButton.Layer.BorderColor = View.TintColor.CGColor; _searchInViewButton.Layer.BorderWidth = 1; _activityView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); _activityView.TranslatesAutoresizingMaskIntoConstraints = false; _activityView.HidesWhenStopped = true; _activityView.BackgroundColor = UIColor.FromWhiteAlpha(0, .5f); _suggestionView = new UITableView(); _suggestionView.TranslatesAutoresizingMaskIntoConstraints = false; _suggestionView.Hidden = true; _mySuggestionSource = new SuggestionSource(null, this); _suggestionView.Source = _mySuggestionSource; _suggestionView.RowHeight = 24; // Add the views. View.AddSubviews(_myMapView, formContainer, _searchBox, _locationBox, _searchButton, _searchInViewButton, _activityView, _suggestionView); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(formContainer.BottomAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), _searchBox.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor, 8), _searchBox.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 8), _searchBox.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -8), _locationBox.TopAnchor.ConstraintEqualTo(_searchBox.BottomAnchor, 8), _locationBox.LeadingAnchor.ConstraintEqualTo(_searchBox.LeadingAnchor), _locationBox.TrailingAnchor.ConstraintEqualTo(_searchBox.TrailingAnchor), _searchButton.TopAnchor.ConstraintEqualTo(_locationBox.BottomAnchor, 8), _searchButton.LeadingAnchor.ConstraintEqualTo(_searchBox.LeadingAnchor), _searchButton.TrailingAnchor.ConstraintEqualTo(View.CenterXAnchor, -4), _searchButton.HeightAnchor.ConstraintEqualTo(32), _searchInViewButton.TopAnchor.ConstraintEqualTo(_searchButton.TopAnchor), _searchInViewButton.LeadingAnchor.ConstraintEqualTo(View.CenterXAnchor, 4), _searchInViewButton.TrailingAnchor.ConstraintEqualTo(_searchBox.TrailingAnchor), _searchInViewButton.HeightAnchor.ConstraintEqualTo(32), formContainer.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), formContainer.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), formContainer.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), formContainer.BottomAnchor.ConstraintEqualTo(_searchInViewButton.BottomAnchor, 8), _activityView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _activityView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _activityView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _activityView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), _suggestionView.TopAnchor.ConstraintEqualTo(formContainer.BottomAnchor, 8), _suggestionView.LeadingAnchor.ConstraintEqualTo(_locationBox.LeadingAnchor, 8), _suggestionView.TrailingAnchor.ConstraintEqualTo(_locationBox.TrailingAnchor, -8), _suggestionView.HeightAnchor.ConstraintEqualTo(_suggestionView.RowHeight * 4) }); }
public PreviewPane(NSImage severityIcon, string id, string title, string description, Uri helpLink, string helpLinkToolTipText, IReadOnlyList <object> previewContent, bool logIdVerbatimInTelemetry, Guid?optionPageGuid = null) { _differenceViewerPreview = (DifferenceViewerPreview)previewContent[0]; var view = ((ICocoaDifferenceViewer)_differenceViewerPreview.Viewer).VisualElement; var originalSize = view.Frame.Size; this.TranslatesAutoresizingMaskIntoConstraints = false; // === Title === // Title is in a stack view to help with padding var titlePlaceholder = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Vertical, EdgeInsets = new NSEdgeInsets(5, 0, 5, 0), Alignment = NSLayoutAttribute.Leading, TranslatesAutoresizingMaskIntoConstraints = false }; // TODO: missing icon this.titleField = new NSTextField() { Editable = false, Bordered = false, BackgroundColor = NSColor.ControlBackground, DrawsBackground = false, }; titlePlaceholder.AddArrangedSubview(titleField); AddSubview(titlePlaceholder); // === Preview View === // This is the actual view, that shows the diff view.TranslatesAutoresizingMaskIntoConstraints = false; NSLayoutConstraint.Create(view, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1, originalSize.Width).Active = true; NSLayoutConstraint.Create(view, NSLayoutAttribute.Height, NSLayoutRelation.GreaterThanOrEqual, 1, originalSize.Height).Active = true; view.Subviews[0].TranslatesAutoresizingMaskIntoConstraints = false; view.WantsLayer = true; AddSubview(view); // === Constraints === var constraints = new NSLayoutConstraint[] { // Title NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0), NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0), NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, 0), // Preview View NSLayoutConstraint.Create(view, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, 0), NSLayoutConstraint.Create(view, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0), NSLayoutConstraint.Create(view, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, 0), // subviews NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1, 0), NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1, 0), NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Left, NSLayoutRelation.Equal, view, NSLayoutAttribute.Left, 1, 0), NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Right, NSLayoutRelation.Equal, view, NSLayoutAttribute.Right, 1, 0), }; if (GenerateAttributeString(id, title, helpLink, helpLinkToolTipText) is NSAttributedString attributedStringTitle) { this.titleField.AttributedStringValue = attributedStringTitle; // We do this separately, because the title sometimes isn't there (i.e. no diagnostics ID) // and we want the preview to stretch to the top NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, titlePlaceholder, NSLayoutAttribute.Bottom, 1, 0).Active = true; } else { NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0).Active = true; } NSLayoutConstraint.ActivateConstraints(constraints); _differenceViewerPreview.Viewer.InlineView.TryMoveCaretToAndEnsureVisible( new Text.SnapshotPoint(_differenceViewerPreview.Viewer.InlineView.TextSnapshot, 0)); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _newMapButton = new UIBarButtonItem(); _newMapButton.Title = "New map"; _basemapButton = new UIBarButtonItem(); _basemapButton.Title = "Basemap"; _layersButton = new UIBarButtonItem(); _layersButton.Title = "Layers"; _saveButton = new UIBarButtonItem(); _saveButton.Title = "Save"; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { _newMapButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _basemapButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _layersButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _saveButton }; _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge) { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = UIColor.FromWhiteAlpha(0f, .8f), HidesWhenStopped = true }; // Add the views. View.AddSubviews(_myMapView, toolbar, _activityIndicator); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _activityIndicator.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _activityIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _activityIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _activityIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _layerList = new UITableView(); _layerList.TranslatesAutoresizingMaskIntoConstraints = false; _layerList.RowHeight = 40; UILabel helpLabel = new UILabel { Text = "Select layers for display.", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; // Add the views. View.AddSubviews(_myMapView, _layerList, helpLabel); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { helpLabel.LeadingAnchor.ConstraintEqualTo(_myMapView.LeadingAnchor), helpLabel.TrailingAnchor.ConstraintEqualTo(_myMapView.TrailingAnchor), helpLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor), helpLabel.HeightAnchor.ConstraintEqualTo(40), }); _portraitConstraints = new[] { _layerList.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _layerList.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _layerList.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _layerList.HeightAnchor.ConstraintEqualTo(_layerList.RowHeight * 4), _myMapView.TopAnchor.ConstraintEqualTo(_layerList.BottomAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor) }; _landscapeConstraints = new[] { _layerList.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _layerList.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _layerList.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), _layerList.TrailingAnchor.ConstraintEqualTo(View.CenterXAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(_layerList.TrailingAnchor), _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor) }; }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); // Skip if already initialized if (_initialized) { return; } if (AllowsManualResize) { _handlebar = new UIView { TranslatesAutoresizingMaskIntoConstraints = false }; _handlebar.Layer.CornerRadius = ApplicationTheme.HandlebarCornerRadius; _handlebar.BackgroundColor = ApplicationTheme.SeparatorColor; _blurView.ContentView.AddSubview(_handlebar); _handlebarSeparator = new UIView { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = ApplicationTheme.SeparatorColor }; _blurView.ContentView.AddSubview(_handlebarSeparator); NSLayoutConstraint.ActivateConstraints(new[] { _handlebar.CenterXAnchor.ConstraintEqualTo(_blurView.CenterXAnchor), _handlebar.HeightAnchor.ConstraintEqualTo(ApplicationTheme.HandlebarThickness), _handlebar.WidthAnchor.ConstraintEqualTo(ApplicationTheme.HandlebarLength), _handlebarSeparator.HeightAnchor.ConstraintEqualTo(0.5f), _handlebarSeparator.LeadingAnchor.ConstraintEqualTo(_blurView.LeadingAnchor), _handlebarSeparator.TrailingAnchor.ConstraintEqualTo(_blurView.TrailingAnchor) }); _blurView.AddGestureRecognizer(_gesture); } NSLayoutConstraint.ActivateConstraints(new[] { DisplayedContentView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor), DisplayedContentView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor), _blurView.TopAnchor.ConstraintGreaterThanOrEqualTo(View.Superview.SafeAreaLayoutGuide.TopAnchor) }); var regularWidthConstraints = new List <NSLayoutConstraint>() { View.LeadingAnchor.ConstraintEqualTo(View.Superview.SafeAreaLayoutGuide.LeadingAnchor, ApplicationTheme.Margin), View.WidthAnchor.ConstraintEqualTo(320), View.TopAnchor.ConstraintEqualTo(View.Superview.SafeAreaLayoutGuide.TopAnchor, ApplicationTheme.Margin), View.BottomAnchor.ConstraintGreaterThanOrEqualTo(View.TopAnchor, MinimumHeight - (2 * ApplicationTheme.Margin)), View.BottomAnchor.ConstraintLessThanOrEqualTo(View.Superview.SafeAreaLayoutGuide.BottomAnchor), DisplayedContentView.TopAnchor.ConstraintEqualTo(View.TopAnchor), }; if (AllowsManualResize) { regularWidthConstraints.Add(_handlebar.BottomAnchor.ConstraintEqualTo(View.BottomAnchor, -(0.5f * ApplicationTheme.Margin))); regularWidthConstraints.Add(DisplayedContentView.BottomAnchor.ConstraintEqualTo(_handlebarSeparator.TopAnchor, -ApplicationTheme.Margin)); regularWidthConstraints.Add(_handlebarSeparator.BottomAnchor.ConstraintEqualTo(_handlebar.TopAnchor, -(0.5f * ApplicationTheme.Margin))); } else { regularWidthConstraints.Add(DisplayedContentView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor)); } _regularWidthConstraints = regularWidthConstraints.ToArray(); var compactWidthConstraints = new List <NSLayoutConstraint> { View.LeadingAnchor.ConstraintEqualTo(View.Superview.LeadingAnchor), View.TrailingAnchor.ConstraintEqualTo(View.Superview.TrailingAnchor), View.BottomAnchor.ConstraintEqualTo(View.Superview.BottomAnchor, ApplicationTheme.Margin), DisplayedContentView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor) }; if (AllowsManualResize) { compactWidthConstraints.Add(_handlebarSeparator.TopAnchor.ConstraintEqualTo(_handlebar.BottomAnchor, (0.5f * ApplicationTheme.Margin))); compactWidthConstraints.Add(_handlebar.TopAnchor.ConstraintEqualTo(View.TopAnchor, ApplicationTheme.Margin)); compactWidthConstraints.Add(DisplayedContentView.TopAnchor.ConstraintEqualTo(_handlebar.BottomAnchor)); } else { compactWidthConstraints.Add(DisplayedContentView.TopAnchor.ConstraintEqualTo(View.TopAnchor)); } _compactWidthConstraints = compactWidthConstraints.ToArray(); _heightConstraint = View.HeightAnchor.ConstraintEqualTo(DefaultPartialHeight); _heightConstraint.Active = true; UpdateInterfaceForCurrentTraits(); _initialized = true; }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; UILabel helpLabel = new UILabel { Text = "Tap the map to create planar and geodesic buffers.", TextAlignment = UITextAlignment.Center, AdjustsFontSizeToFitWidth = true, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; UIView formArea = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; formArea.TranslatesAutoresizingMaskIntoConstraints = false; UILabel bufferInputLabel = new UILabel { Text = "Distance (miles):", TextAlignment = UITextAlignment.Right, TranslatesAutoresizingMaskIntoConstraints = false }; _bufferDistanceMilesTextField = new UITextField { BackgroundColor = UIColor.LightGray, KeyboardType = UIKeyboardType.NumberPad, Text = "1000", TextAlignment = UITextAlignment.Right, TranslatesAutoresizingMaskIntoConstraints = false }; _bufferDistanceMilesTextField.Layer.CornerRadius = 5; // Add padding within the field. _bufferDistanceMilesTextField.RightView = new UIView(new CGRect(0, 0, 5, 20)); // 5 is amount of left padding. _bufferDistanceMilesTextField.RightViewMode = UITextFieldViewMode.Always; UIStackView legendView = new UIStackView(); legendView.TranslatesAutoresizingMaskIntoConstraints = false; legendView.Axis = UILayoutConstraintAxis.Horizontal; legendView.Alignment = UIStackViewAlignment.Center; legendView.Spacing = 8; _geodesicSwatchSwatch = new UIView(); _geodesicSwatchSwatch.TranslatesAutoresizingMaskIntoConstraints = false; _geodesicSwatchSwatch.BackgroundColor = UIColor.Red; _geodesicSwatchSwatch.WidthAnchor.ConstraintEqualTo(16).Active = true; _geodesicSwatchSwatch.HeightAnchor.ConstraintEqualTo(16).Active = true; _geodesicSwatchSwatch.ClipsToBounds = true; _geodesicSwatchSwatch.Layer.CornerRadius = 8; legendView.AddArrangedSubview(_geodesicSwatchSwatch); UILabel geodesicSwatchLabel = new UILabel { Text = "Geodesic buffers", TextColor = UIColor.Red, TranslatesAutoresizingMaskIntoConstraints = false }; legendView.AddArrangedSubview(geodesicSwatchLabel); UIView spacer = new UIView(); spacer.TranslatesAutoresizingMaskIntoConstraints = false; spacer.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultLow, UILayoutConstraintAxis.Horizontal); legendView.AddArrangedSubview(spacer); _planarSwatchSwatch = new UIView(); _planarSwatchSwatch.BackgroundColor = UIColor.Blue; _planarSwatchSwatch.TranslatesAutoresizingMaskIntoConstraints = false; _planarSwatchSwatch.WidthAnchor.ConstraintEqualTo(16).Active = true; _planarSwatchSwatch.HeightAnchor.ConstraintEqualTo(16).Active = true; _planarSwatchSwatch.ClipsToBounds = true; _planarSwatchSwatch.Layer.CornerRadius = 8; legendView.AddArrangedSubview(_planarSwatchSwatch); UILabel planarSwatchLabel = new UILabel { Text = "Planar buffers", TextColor = UIColor.Blue, TranslatesAutoresizingMaskIntoConstraints = false }; legendView.AddArrangedSubview(planarSwatchLabel); _clearBuffersButton = new UIButton { ClipsToBounds = true, BackgroundColor = View.TintColor }; _clearBuffersButton.SetTitle("Clear", UIControlState.Normal); _clearBuffersButton.SetTitleColor(ApplicationTheme.ForegroundColor, UIControlState.Normal); _clearBuffersButton.Layer.CornerRadius = 5; _clearBuffersButton.TranslatesAutoresizingMaskIntoConstraints = false; // Add the views. View.AddSubviews(_myMapView, formArea, helpLabel, bufferInputLabel, _bufferDistanceMilesTextField, legendView, _clearBuffersButton); // Lay out the views. // TODO: consider replacing with UIStackView-based layout. nfloat margin = 8; nfloat controlHeight = 4 * margin; NSLayoutConstraint.ActivateConstraints(new[] { formArea.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), formArea.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), formArea.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), formArea.HeightAnchor.ConstraintEqualTo((3 * margin) + (2 * controlHeight)), legendView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 8), legendView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -8), legendView.TopAnchor.ConstraintEqualTo(formArea.BottomAnchor), legendView.HeightAnchor.ConstraintEqualTo(24), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.TopAnchor.ConstraintEqualTo(legendView.BottomAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), helpLabel.TopAnchor.ConstraintEqualTo(formArea.TopAnchor, margin), helpLabel.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor), helpLabel.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor), helpLabel.HeightAnchor.ConstraintEqualTo(controlHeight), bufferInputLabel.TopAnchor.ConstraintEqualTo(helpLabel.BottomAnchor, margin), bufferInputLabel.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, margin), bufferInputLabel.TrailingAnchor.ConstraintEqualTo(formArea.CenterXAnchor, -margin), bufferInputLabel.HeightAnchor.ConstraintEqualTo(controlHeight), _bufferDistanceMilesTextField.TopAnchor.ConstraintEqualTo(bufferInputLabel.TopAnchor), _bufferDistanceMilesTextField.LeadingAnchor.ConstraintEqualTo(formArea.CenterXAnchor, margin), _bufferDistanceMilesTextField.TrailingAnchor.ConstraintEqualTo(_clearBuffersButton.LeadingAnchor, -margin), _bufferDistanceMilesTextField.HeightAnchor.ConstraintEqualTo(controlHeight), _clearBuffersButton.TopAnchor.ConstraintEqualTo(_bufferDistanceMilesTextField.TopAnchor), _clearBuffersButton.WidthAnchor.ConstraintEqualTo(100), _clearBuffersButton.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -margin), _clearBuffersButton.HeightAnchor.ConstraintEqualTo(controlHeight) }); }
internal RoutePlanningCard(MapViewModel viewModel) { _viewModel = viewModel; _startTextPlaceholder = new PseudoTextFieldButton { TranslatesAutoresizingMaskIntoConstraints = false }; _endTextPlaceholder = new PseudoTextFieldButton { TranslatesAutoresizingMaskIntoConstraints = false }; var searchRouteButton = new ActionButton { TranslatesAutoresizingMaskIntoConstraints = false }; searchRouteButton.SetTitle("SearchForRouteButtonText".Localize(), UIControlState.Normal); UIButton cancelRouteSearchButton = new CloseButton { TranslatesAutoresizingMaskIntoConstraints = false }; var searchStartLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "OriginRouteSearchFieldLabel".Localize() }; var searchEndLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "DestinationRouteSearchFieldLabel".Localize() }; searchStartLabel.SetContentHuggingPriority((float)UILayoutPriority.DefaultHigh, UILayoutConstraintAxis.Horizontal); var routeSearchHeader = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "DirectionsPanelHeader".Localize(), TextColor = ApplicationTheme.ForegroundColor, Font = ApplicationTheme.HeaderFont }; // swap origin and destination button var swapOriginDestinationButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false }; swapOriginDestinationButton.SetImage(UIImage.FromBundle("arrow-up-down"), UIControlState.Normal); swapOriginDestinationButton.TintColor = ApplicationTheme.ForegroundColor; AddSubviews(_startTextPlaceholder, _endTextPlaceholder, searchRouteButton, searchStartLabel, searchEndLabel, cancelRouteSearchButton, routeSearchHeader, swapOriginDestinationButton); NSLayoutConstraint.ActivateConstraints(new[] { // label routeSearchHeader.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), routeSearchHeader.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), routeSearchHeader.TrailingAnchor.ConstraintEqualTo(cancelRouteSearchButton.LeadingAnchor, -ApplicationTheme.Margin), // close button cancelRouteSearchButton.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), cancelRouteSearchButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), cancelRouteSearchButton.HeightAnchor.ConstraintEqualTo(32), cancelRouteSearchButton.WidthAnchor.ConstraintEqualTo(32), // labels searchStartLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), searchStartLabel.CenterYAnchor.ConstraintEqualTo(_startTextPlaceholder.CenterYAnchor), searchEndLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), searchEndLabel.CenterYAnchor.ConstraintEqualTo(_endTextPlaceholder.CenterYAnchor), searchEndLabel.TrailingAnchor.ConstraintEqualTo(searchStartLabel.TrailingAnchor), // search bars _startTextPlaceholder.LeadingAnchor.ConstraintEqualTo(searchStartLabel.TrailingAnchor, ApplicationTheme.Margin), _startTextPlaceholder.TopAnchor.ConstraintEqualTo(routeSearchHeader.BottomAnchor, ApplicationTheme.Margin), _startTextPlaceholder.TrailingAnchor.ConstraintEqualTo(swapOriginDestinationButton.LeadingAnchor, -ApplicationTheme.Margin), _startTextPlaceholder.HeightAnchor.ConstraintEqualTo(44), _endTextPlaceholder.LeadingAnchor.ConstraintEqualTo(_startTextPlaceholder.LeadingAnchor), _endTextPlaceholder.TrailingAnchor.ConstraintEqualTo(_startTextPlaceholder.TrailingAnchor), _endTextPlaceholder.TopAnchor.ConstraintEqualTo(_startTextPlaceholder.BottomAnchor, ApplicationTheme.Margin), _endTextPlaceholder.HeightAnchor.ConstraintEqualTo(44), // swap origin and destinations button swapOriginDestinationButton.HeightAnchor.ConstraintEqualTo(32), swapOriginDestinationButton.WidthAnchor.ConstraintEqualTo(32), swapOriginDestinationButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), swapOriginDestinationButton.CenterYAnchor.ConstraintEqualTo(_endTextPlaceholder.CenterYAnchor), // search button searchRouteButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), searchRouteButton.TopAnchor.ConstraintEqualTo(_endTextPlaceholder.BottomAnchor, ApplicationTheme.Margin), searchRouteButton.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), // constrains view bottom to bottom of last element BottomAnchor.ConstraintEqualTo(searchRouteButton.BottomAnchor, ApplicationTheme.Margin) }); searchRouteButton.TouchUpInside += SearchRouteButton_Clicked; cancelRouteSearchButton.TouchUpInside += CancelRouteSearchButton_Clicked; swapOriginDestinationButton.TouchUpInside += SwapOriginDestinationButton_Clicked; _startTextPlaceholder.Tapped += EditOriginField_Clicked; _endTextPlaceholder.Tapped += EditDestinationField_Clicked; _viewModel.PropertyChanged += ViewModel_PropertyChanged; }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; _mapView = new MapView(); _mapView.TranslatesAutoresizingMaskIntoConstraints = false; _transactionButton = new UIBarButtonItem(); _transactionButton.Title = "Start transaction"; _syncButton = new UIBarButtonItem(); _syncButton.Title = "Sync"; _addButton = new UIBarButtonItem(UIBarButtonSystemItem.Add); _addButton.Enabled = false; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { _transactionButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _syncButton, _addButton }; _transactionSwitch = new UISwitch(); _transactionSwitch.TranslatesAutoresizingMaskIntoConstraints = false; _transactionSwitch.On = true; _statusLabel = new UILabel { Text = "Preparing sample data...", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 2, TranslatesAutoresizingMaskIntoConstraints = false }; _statusLabel.TranslatesAutoresizingMaskIntoConstraints = false; UILabel requireTransactionsLabel = new UILabel(); requireTransactionsLabel.TranslatesAutoresizingMaskIntoConstraints = false; requireTransactionsLabel.Text = "Require transaction"; requireTransactionsLabel.TextAlignment = UITextAlignment.Right; requireTransactionsLabel.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultHigh, UILayoutConstraintAxis.Horizontal); UIStackView requireTransactionRow = new UIStackView(new UIView[] { requireTransactionsLabel, _transactionSwitch }); requireTransactionRow.TranslatesAutoresizingMaskIntoConstraints = false; requireTransactionRow.Axis = UILayoutConstraintAxis.Horizontal; requireTransactionRow.Distribution = UIStackViewDistribution.Fill; requireTransactionRow.Spacing = 8; requireTransactionRow.LayoutMarginsRelativeArrangement = true; requireTransactionRow.LayoutMargins = new UIEdgeInsets(8, 8, 8, 8); _progressBar = new UIProgressView(UIProgressViewStyle.Bar); _progressBar.TranslatesAutoresizingMaskIntoConstraints = false; // Add the views. View.AddSubviews(_mapView, _statusLabel, requireTransactionRow, toolbar, _progressBar); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _mapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _mapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _mapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _mapView.BottomAnchor.ConstraintEqualTo(requireTransactionRow.TopAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), requireTransactionRow.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor), requireTransactionRow.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor), requireTransactionRow.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), _statusLabel.TopAnchor.ConstraintEqualTo(_mapView.TopAnchor), _statusLabel.LeadingAnchor.ConstraintEqualTo(_mapView.LeadingAnchor), _statusLabel.TrailingAnchor.ConstraintEqualTo(_mapView.TrailingAnchor), _statusLabel.HeightAnchor.ConstraintEqualTo(80), _progressBar.TopAnchor.ConstraintEqualTo(_statusLabel.BottomAnchor), _progressBar.LeadingAnchor.ConstraintEqualTo(_statusLabel.LeadingAnchor), _progressBar.TrailingAnchor.ConstraintEqualTo(_statusLabel.TrailingAnchor), _progressBar.HeightAnchor.ConstraintEqualTo(8) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _helpButton = new UIBarButtonItem("Help", UIBarButtonItemStyle.Plain, ShowHelpAlert); _resetButton = new UIBarButtonItem("Reset", UIBarButtonItemStyle.Plain, ClearButton_Click); _bufferButton = new UIBarButtonItem("Buffer", UIBarButtonItemStyle.Plain, PromptForUnionChoice); UIToolbar controlsToolbar = new UIToolbar(); controlsToolbar.TranslatesAutoresizingMaskIntoConstraints = false; controlsToolbar.Items = new[] { _helpButton, // Put a space between the buttons new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _bufferButton, _resetButton }; UIToolbar entryToolbar = new UIToolbar(); entryToolbar.TranslatesAutoresizingMaskIntoConstraints = false; _bufferDistanceEntry = new UITextField(); _bufferDistanceEntry.TranslatesAutoresizingMaskIntoConstraints = false; _bufferDistanceEntry.Text = "10"; _bufferDistanceEntry.BackgroundColor = UIColor.FromWhiteAlpha(1, .8f); _bufferDistanceEntry.Layer.CornerRadius = 4; _bufferDistanceEntry.LeftView = new UIView(new CGRect(0, 0, 5, 20)); _bufferDistanceEntry.LeftViewMode = UITextFieldViewMode.Always; _bufferDistanceEntry.KeyboardType = UIKeyboardType.NumberPad; // Allow pressing 'return' to dismiss the keyboard. _bufferDistanceEntry.ShouldReturn += textField => { textField.ResignFirstResponder(); return(true); }; UILabel bufferDistanceEntryLabel = new UILabel(); bufferDistanceEntryLabel.TranslatesAutoresizingMaskIntoConstraints = false; bufferDistanceEntryLabel.Text = "Buffer size:"; // Add the views. View.AddSubviews(_myMapView, controlsToolbar, entryToolbar, bufferDistanceEntryLabel, _bufferDistanceEntry); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new [] { entryToolbar.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), entryToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), entryToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), bufferDistanceEntryLabel.LeadingAnchor.ConstraintEqualTo(entryToolbar.LayoutMarginsGuide.LeadingAnchor, 8), bufferDistanceEntryLabel.CenterYAnchor.ConstraintEqualTo(entryToolbar.CenterYAnchor), _bufferDistanceEntry.TrailingAnchor.ConstraintEqualTo(entryToolbar.LayoutMarginsGuide.TrailingAnchor), _bufferDistanceEntry.CenterYAnchor.ConstraintEqualTo(entryToolbar.CenterYAnchor), _bufferDistanceEntry.LeadingAnchor.ConstraintEqualTo(bufferDistanceEntryLabel.TrailingAnchor, 8), _myMapView.TopAnchor.ConstraintEqualTo(entryToolbar.BottomAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(controlsToolbar.TopAnchor), controlsToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), controlsToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), controlsToolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _resultLabel = new UILabel { Text = "Adjust the slider to start.", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; _operationPicker = new UISegmentedControl("Densify", "Generalize"); _operationPicker.TranslatesAutoresizingMaskIntoConstraints = false; _operationPicker.SelectedSegment = 0; _slider = new UISlider(); _slider.TranslatesAutoresizingMaskIntoConstraints = false; _slider.MinValue = 100; _slider.MaxValue = 500; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { new UIBarButtonItem { CustomView = _operationPicker }, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem { CustomView = _slider, Width = 150 } }; // Add the views. View.AddSubviews(_myMapView, toolbar, _resultLabel); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), _resultLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor), _resultLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _resultLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _resultLabel.HeightAnchor.ConstraintEqualTo(40) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; UIToolbar controlToolbox = new UIToolbar(); controlToolbox.TranslatesAutoresizingMaskIntoConstraints = false; _mySceneView = new SceneView(); _mySceneView.TranslatesAutoresizingMaskIntoConstraints = false; _insetMapView = new MapView(); _insetMapView.TranslatesAutoresizingMaskIntoConstraints = false; _insetMapView.IsAttributionTextVisible = false; _playButton = new UIBarButtonItem(); _playButton.Title = "Pause"; _playButton.Width = 100; _missionButton = new UIBarButtonItem(); _missionButton.Title = "Mission"; _cameraButton = new UIBarButtonItem(); _cameraButton.Title = "Camera"; _statsButton = new UIBarButtonItem(); _statsButton.Title = "Stats"; controlToolbox.Items = new[] { _missionButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _cameraButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _playButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _statsButton }; // Add the views. View.AddSubviews(_mySceneView, _insetMapView, controlToolbox); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { controlToolbox.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), controlToolbox.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), controlToolbox.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), _mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _mySceneView.BottomAnchor.ConstraintEqualTo(controlToolbox.TopAnchor), _insetMapView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 16), _insetMapView.BottomAnchor.ConstraintEqualTo(_mySceneView.BottomAnchor, -40), _insetMapView.WidthAnchor.ConstraintEqualTo(96), _insetMapView.HeightAnchor.ConstraintEqualTo(96) }); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.AddGestureRecognizer(new UITapGestureRecognizer(() => DismissViewController(true, null))); View.BackgroundColor = UIColor.Black.ColorWithAlpha(0.5f); UIView frame = new UIView { BackgroundColor = UIColor.White, Layer = { CornerRadius = 13 }, TranslatesAutoresizingMaskIntoConstraints = false }; // Pickers var hoursPicker = new UIPickerView() { TranslatesAutoresizingMaskIntoConstraints = false, DataSource = new NumberPickerViewDataSource(100), Delegate = new NumberPickerViewDelegate() }; hoursPicker.Select((nint)Math.Floor(_Timespan.TotalHours), 0, false); var minutesPicker = new UIPickerView() { TranslatesAutoresizingMaskIntoConstraints = false, DataSource = new NumberPickerViewDataSource(60), Delegate = new NumberPickerViewDelegate() }; minutesPicker.Select(_Timespan.Minutes, 0, false); UILabel titleLabel = null; if (!string.IsNullOrWhiteSpace(_Title)) { titleLabel = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = _Title, Font = UIFont.PreferredHeadline, Lines = 2, LineBreakMode = UILineBreakMode.WordWrap | UILineBreakMode.TailTruncation }; } UILabel messageLabel = null; if (!string.IsNullOrWhiteSpace(_Message)) { messageLabel = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = _Message, Font = UIFont.PreferredSubheadline }; } // Pickers labels var hoursLabel = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Hours", Font = UIFont.PreferredSubheadline, TextAlignment = UITextAlignment.Center }; var minutesLabel = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Minutes", Font = UIFont.PreferredSubheadline, TextAlignment = UITextAlignment.Center }; var affirmButton = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false, }; affirmButton.SetTitle(_AffirmButton ?? "OK", UIControlState.Normal); affirmButton.TouchUpInside += (sender, args) => { _OnAffirm?.Invoke(new TimeSpan((int)hoursPicker.SelectedRowInComponent(0), (int)minutesPicker.SelectedRowInComponent(0), 0)); DismissViewController(true, null); }; var denyButton = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; denyButton.SetTitle(_DenyButton ?? "Cancel", UIControlState.Normal); denyButton.TouchUpInside += (sender, args) => { _OnDeny?.Invoke(); DismissViewController(true, null); }; // Separators var separatorColor = UIColor.FromRGB(235, 235, 240); var horizontalSeparator = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = separatorColor }; var verticalSeparator = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = separatorColor }; frame.AddSubview(hoursPicker); frame.AddSubview(minutesPicker); if (titleLabel != null) { frame.AddSubview(titleLabel); } if (messageLabel != null) { frame.AddSubview(messageLabel); } frame.AddSubview(hoursLabel); frame.AddSubview(minutesLabel); frame.AddSubview(affirmButton); frame.AddSubview(denyButton); frame.AddSubview(horizontalSeparator); frame.AddSubview(verticalSeparator); View.AddSubview(frame); if (titleLabel != null) { // Title constrains titleLabel.TopAnchor.ConstraintEqualTo(frame.TopAnchor, 20).Active = true; titleLabel.CenterXAnchor.ConstraintEqualTo(frame.CenterXAnchor).Active = true; } if (messageLabel != null) { if (titleLabel == null) { messageLabel.TopAnchor.ConstraintEqualTo(frame.TopAnchor, 20).Active = true; } else { messageLabel.TopAnchor.ConstraintEqualTo(titleLabel.BottomAnchor, 10).Active = true; } messageLabel.CenterXAnchor.ConstraintEqualTo(frame.CenterXAnchor).Active = true; } // Hours, minutes labels constraints if (messageLabel != null) { hoursLabel.TopAnchor.ConstraintEqualTo(messageLabel.BottomAnchor, 20).Active = true; } else if (titleLabel != null) { hoursLabel.TopAnchor.ConstraintEqualTo(titleLabel.BottomAnchor, 20).Active = true; } else { hoursLabel.TopAnchor.ConstraintEqualTo(frame.TopAnchor, 20).Active = true; } hoursLabel.LeftAnchor.ConstraintEqualTo(frame.LeftAnchor).Active = true; minutesLabel.TopAnchor.ConstraintEqualTo(hoursLabel.TopAnchor).Active = true; minutesLabel.RightAnchor.ConstraintEqualTo(frame.RightAnchor).Active = true; hoursLabel.RightAnchor.ConstraintEqualTo(minutesLabel.LeftAnchor).Active = true; minutesLabel.WidthAnchor.ConstraintEqualTo(hoursLabel.WidthAnchor).Active = true; NSLayoutConstraint.ActivateConstraints(new[] { // pickers constrains hoursPicker.TopAnchor.ConstraintEqualTo(hoursLabel.BottomAnchor), hoursPicker.HeightAnchor.ConstraintEqualTo(100), hoursPicker.LeftAnchor.ConstraintEqualTo(frame.LeftAnchor), minutesPicker.HeightAnchor.ConstraintEqualTo(hoursPicker.HeightAnchor), minutesPicker.TopAnchor.ConstraintEqualTo(hoursPicker.TopAnchor), minutesPicker.RightAnchor.ConstraintEqualTo(frame.RightAnchor), hoursPicker.RightAnchor.ConstraintEqualTo(minutesPicker.LeftAnchor), hoursPicker.WidthAnchor.ConstraintEqualTo(minutesPicker.WidthAnchor), // Affirm, Deny button constrains and separators verticalSeparator.WidthAnchor.ConstraintEqualTo(1), horizontalSeparator.HeightAnchor.ConstraintEqualTo(1), horizontalSeparator.TopAnchor.ConstraintEqualTo(hoursPicker.BottomAnchor, 5), horizontalSeparator.LeftAnchor.ConstraintEqualTo(frame.LeftAnchor), horizontalSeparator.RightAnchor.ConstraintEqualTo(frame.RightAnchor), verticalSeparator.TopAnchor.ConstraintEqualTo(horizontalSeparator.BottomAnchor), verticalSeparator.CenterXAnchor.ConstraintEqualTo(frame.CenterXAnchor), verticalSeparator.BottomAnchor.ConstraintEqualTo(frame.BottomAnchor), affirmButton.TopAnchor.ConstraintEqualTo(horizontalSeparator.BottomAnchor), affirmButton.LeftAnchor.ConstraintEqualTo(verticalSeparator.RightAnchor), affirmButton.RightAnchor.ConstraintEqualTo(frame.RightAnchor), affirmButton.BottomAnchor.ConstraintEqualTo(frame.BottomAnchor), affirmButton.HeightAnchor.ConstraintEqualTo(40), denyButton.TopAnchor.ConstraintEqualTo(horizontalSeparator.BottomAnchor), denyButton.RightAnchor.ConstraintEqualTo(verticalSeparator.LeftAnchor), denyButton.LeftAnchor.ConstraintEqualTo(frame.LeftAnchor), denyButton.BottomAnchor.ConstraintEqualTo(frame.BottomAnchor), denyButton.HeightAnchor.ConstraintEqualTo(40), // Frame constrains frame.CenterXAnchor.ConstraintEqualTo(View.CenterXAnchor), frame.CenterYAnchor.ConstraintEqualTo(View.CenterYAnchor), frame.WidthAnchor.ConstraintEqualTo(300) }); }
public override void OnViewModelLoadedOverride() { bool isTask = ViewModel.Item.Type == TaskOrEventType.Task; BindingHost.SetBinding <string>(nameof(ViewModel.PageTitle), (t) => Title = StringWithCapitals(t)); var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit); buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler; var buttonMore = new UIBarButtonItem(UIImage.FromBundle("MenuVerticalIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, new WeakEventHandler(ButtonMore_Clicked).Handler); NavItem.RightBarButtonItems = new UIBarButtonItem[] { buttonMore, buttonEdit }; int bottomSliderHeight = isTask ? CIRCLE_BUTTON_HEIGHT + 16 + 16 : 0; _scrollView = new UIScrollView() { TranslatesAutoresizingMaskIntoConstraints = false, ShowsHorizontalScrollIndicator = false }; base.ContentView.AddSubview(_scrollView); _scrollView.StretchWidthAndHeight(base.ContentView, bottom: bottomSliderHeight); _stackView = new UIStackView() { TranslatesAutoresizingMaskIntoConstraints = false, Axis = UILayoutConstraintAxis.Vertical }; _scrollView.AddSubview(_stackView); _stackView.ConfigureForVerticalScrolling(_scrollView, top: 16, bottom: 16, left: 16, right: 16); _itemBindingHost = new BindingHost() { BindingObject = ViewModel.Item }; _classBindingHost = new BindingHost(); _itemBindingHost.SetBinding(nameof(ViewItemTaskOrEvent.Class), delegate { _classBindingHost.BindingObject = ViewModel.Item.Class; }); var labelTitle = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredTitle3, Lines = 0 }; _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Item.Name)); _stackView.AddArrangedSubview(labelTitle); labelTitle.StretchWidth(_stackView); _stackView.AddArrangedSubview(new UIView().SetHeight(4)); var labelSubtitle = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredSubheadline, Lines = 0 }; _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemTaskOrEvent.Subtitle)); _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) => { labelSubtitle.TextColor = BareUIHelper.ToColor(color); }); _stackView.AddArrangedSubview(labelSubtitle); labelSubtitle.StretchWidth(_stackView); _stackView.AddArrangedSubview(new UIView().SetHeight(4)); _stackView.AddSpacing(12); var textViewDetails = new UITextView() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredBody, TextColor = UIColor.DarkGray, Editable = false, ScrollEnabled = false, // Link detection: http://iosdevelopertips.com/user-interface/creating-clickable-hyperlinks-from-a-url-phone-number-or-address.html DataDetectorTypes = UIDataDetectorType.All }; // Lose the padding: https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview textViewDetails.TextContainerInset = UIEdgeInsets.Zero; textViewDetails.TextContainer.LineFragmentPadding = 0; _itemBindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewItemTaskOrEvent.Details)); _stackView.AddArrangedSubview(textViewDetails); textViewDetails.StretchWidth(_stackView); if (ViewModel.IsUnassigedMode) { var buttonConvertToGrade = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; buttonConvertToGrade.SetTitle("Convert To Grade", UIControlState.Normal); buttonConvertToGrade.SetTitleColor(new UIColor(1, 1), UIControlState.Normal); buttonConvertToGrade.BackgroundColor = ColorResources.PowerPlannerAccentBlue; buttonConvertToGrade.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.ConvertToGrade(); }).Handler; base.ContentView.Add(buttonConvertToGrade); // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { buttonConvertToGrade.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16), buttonConvertToGrade.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16), buttonConvertToGrade.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16) }); } else { buttonConvertToGrade.StretchWidth(base.ContentView, left: 16, right: 16); buttonConvertToGrade.PinToBottom(base.ContentView, bottom: 16); } } else { var completionSliderVisibilityContainer = new BareUIVisibilityContainer() { TranslatesAutoresizingMaskIntoConstraints = false }; { var completionSliderContainer = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; { _completionSlider = new UISlider() { TranslatesAutoresizingMaskIntoConstraints = false, MaxValue = 1, MinValue = 0, MinimumTrackTintColor = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f), ThumbTintColor = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f) }; _itemBindingHost.SetSliderBinding(_completionSlider, nameof(ViewItemTaskOrEvent.PercentComplete)); _completionSlider.TouchUpInside += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler; _completionSlider.TouchUpOutside += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler; completionSliderContainer.Add(_completionSlider); _completionSlider.StretchHeight(completionSliderContainer); _completionSlider.StretchWidth(completionSliderContainer, left: CIRCLE_BUTTON_HEIGHT + 8, right: CIRCLE_BUTTON_HEIGHT + 8); var incompleteImageContainer = new UIControl() { TranslatesAutoresizingMaskIntoConstraints = false }; { _incompleteImageView = new UIImageView() { TranslatesAutoresizingMaskIntoConstraints = false, ContentMode = UIViewContentMode.ScaleAspectFit, TintColor = UIColor.LightGray }; incompleteImageContainer.Add(_incompleteImageView); _incompleteImageView.StretchHeight(incompleteImageContainer); _incompleteImageView.SetWidth(CIRCLE_BUTTON_HEIGHT); _incompleteImageView.PinToLeft(incompleteImageContainer); } incompleteImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 0; ViewModel.SetPercentComplete(0); UpdateSliderImages(); }).Handler; completionSliderContainer.Add(incompleteImageContainer); incompleteImageContainer.StretchHeight(completionSliderContainer); incompleteImageContainer.PinToLeft(completionSliderContainer); incompleteImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT); var completeImageContainer = new UIControl() { TranslatesAutoresizingMaskIntoConstraints = false }; { _completeImageView = new UIImageView() { TranslatesAutoresizingMaskIntoConstraints = false, ContentMode = UIViewContentMode.ScaleAspectFit, TintColor = UIColor.LightGray }; completeImageContainer.Add(_completeImageView); _completeImageView.StretchHeight(completeImageContainer); _completeImageView.SetWidth(CIRCLE_BUTTON_HEIGHT); _completeImageView.PinToRight(completeImageContainer); } completeImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 1; ViewModel.SetPercentComplete(1); UpdateSliderImages(); }).Handler; completionSliderContainer.Add(completeImageContainer); completeImageContainer.StretchHeight(completionSliderContainer); completeImageContainer.PinToRight(completionSliderContainer); completeImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT); _completionSlider.ValueChanged += new WeakEventHandler(delegate { UpdateSliderImages(); }).Handler; } completionSliderContainer.SetHeight(CIRCLE_BUTTON_HEIGHT); completionSliderVisibilityContainer.Child = completionSliderContainer; } BindingHost.SetVisibilityBinding(completionSliderVisibilityContainer, nameof(ViewModel.IsCompletionSliderVisible)); base.ContentView.Add(completionSliderVisibilityContainer); // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { completionSliderVisibilityContainer.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16), completionSliderVisibilityContainer.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16), completionSliderVisibilityContainer.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16) }); } else { completionSliderVisibilityContainer.StretchWidth(base.ContentView, left: 16, right: 16); completionSliderVisibilityContainer.PinToBottom(base.ContentView, bottom: 16); } _itemBindingHost.SetBinding(nameof(ViewItemTaskOrEvent.PercentComplete), UpdateSliderImages); } base.OnViewModelLoadedOverride(); }
public override void LoadView() { // Create the UI for the symbol selection. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; // A vertical stack view to contain all the controls. _outerStackView = new UIStackView { Axis = UILayoutConstraintAxis.Vertical, TranslatesAutoresizingMaskIntoConstraints = false, Spacing = 2, Distribution = UIStackViewDistribution.EqualSpacing, Alignment = UIStackViewAlignment.Center }; // A vertical stack view to contain the symbol layer picker. UIStackView pickersView = new UIStackView { Axis = UILayoutConstraintAxis.Vertical, TranslatesAutoresizingMaskIntoConstraints = false, Distribution = UIStackViewDistribution.EqualSpacing, Alignment = UIStackViewAlignment.Top }; // Add the symbol layer picker to the stack view. pickersView.AddArrangedSubview(_symbolLayersPicker); // Add the picker stack view to the outer stack view. _outerStackView.AddArrangedSubview(pickersView); // Create a label to show the size of the symbol (specified with the slider). UILabel sizeLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = $"Size: {_sizeSlider.Value:0}" }; // Handle the slider value changed event to update the label with the specified size. _sizeSlider.ValueChanged += async(sender, e) => { sizeLabel.Text = $"Size: {_sizeSlider.Value:0}"; await UpdateSymbol(); }; _sizeSlider.TranslatesAutoresizingMaskIntoConstraints = false; // Create a vertical stack view to contain the color segmented control, size slider, and size label. UIStackView colorSizeStack = new UIStackView(new UIView[] { _colorSegments, _sizeSlider, sizeLabel }) { TranslatesAutoresizingMaskIntoConstraints = false, Axis = UILayoutConstraintAxis.Vertical, Alignment = UIStackViewAlignment.Center, Distribution = UIStackViewDistribution.Fill }; // Add the color and size stack view to the outer stack view. _outerStackView.AddArrangedSubview(colorSizeStack); // Add the preview image view to the outer stack view. _outerStackView.AddArrangedSubview(_symbolPreviewImageView); // Add the outer stack view to the main view. View.AddSubview(_outerStackView); // Set constraints on the outer stack view. NSLayoutConstraint.ActivateConstraints(new[] { _outerStackView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 8), _outerStackView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -8), _outerStackView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor, 8), _outerStackView.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor, -8), _sizeSlider.LeftAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeftAnchor, 20), _sizeSlider.RightAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.RightAnchor, -20) }); }
internal RouteResultCard(MapViewModel viewModel) { _viewModel = viewModel; _stopsTable = new SelfSizedTableView { TranslatesAutoresizingMaskIntoConstraints = false, ScrollEnabled = false, BackgroundColor = UIColor.Clear, AllowsSelection = false }; // Future - consider supporting more travel modes? var travelModeImageView = new UIImageView(UIImage.FromBundle("walking")) { TranslatesAutoresizingMaskIntoConstraints = false, TintColor = ApplicationTheme.PrimaryLabelColor, ContentMode = UIViewContentMode.ScaleAspectFit }; _routeDurationLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false }; UIButton closeButton = new CloseButton { TranslatesAutoresizingMaskIntoConstraints = false }; var headerLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "RouteResultHeader".Localize(), Font = ApplicationTheme.HeaderFont, TextColor = ApplicationTheme.ForegroundColor }; AddSubviews(_stopsTable, travelModeImageView, _routeDurationLabel, closeButton, headerLabel); NSLayoutConstraint.ActivateConstraints(new[] { // result header headerLabel.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), headerLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), headerLabel.TrailingAnchor.ConstraintEqualTo(closeButton.LeadingAnchor, -ApplicationTheme.Margin), // close button closeButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), closeButton.CenterYAnchor.ConstraintEqualTo(headerLabel.CenterYAnchor), closeButton.WidthAnchor.ConstraintEqualTo(32), closeButton.HeightAnchor.ConstraintEqualTo(32), // stops view _stopsTable.LeadingAnchor.ConstraintEqualTo(LeadingAnchor), _stopsTable.TopAnchor.ConstraintEqualTo(_routeDurationLabel.BottomAnchor, ApplicationTheme.Margin), _stopsTable.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), // image travelModeImageView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), travelModeImageView.TopAnchor.ConstraintEqualTo(_routeDurationLabel.TopAnchor), travelModeImageView.BottomAnchor.ConstraintEqualTo(_routeDurationLabel.BottomAnchor), travelModeImageView.WidthAnchor.ConstraintEqualTo(32), // walk time label _routeDurationLabel.TopAnchor.ConstraintEqualTo(headerLabel.BottomAnchor, ApplicationTheme.Margin), _routeDurationLabel.LeadingAnchor.ConstraintEqualTo(travelModeImageView.TrailingAnchor, ApplicationTheme.Margin), // constrains view bottom to bottom of last element BottomAnchor.ConstraintEqualTo(_stopsTable.BottomAnchor, ApplicationTheme.Margin) }); closeButton.TouchUpInside += Close_Clicked; _viewModel.PropertyChanged += ViewModel_PropertyChanged; }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _showOnlineButton = new UIBarButtonItem("Show online", UIBarButtonItemStyle.Plain, ShowOnline_Click) { Enabled = false }; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { new UIBarButtonItem("Download", UIBarButtonItemStyle.Plain, ShowAreas_Click), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Delete all", UIBarButtonItemStyle.Plain, DeleteAreas_Click), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _showOnlineButton }; _helpLabel = new UILabel { Text = "Choose a map area to take offline.", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); _activityIndicator.TranslatesAutoresizingMaskIntoConstraints = false; _activityIndicator.HidesWhenStopped = true; _activityIndicator.BackgroundColor = UIColor.FromWhiteAlpha(0, .6f); _activityIndicator.StartAnimating(); // Add the views. View.AddSubviews(_myMapView, toolbar, _helpLabel, _activityIndicator); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), _helpLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _helpLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _helpLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _helpLabel.HeightAnchor.ConstraintEqualTo(40), _activityIndicator.TopAnchor.ConstraintEqualTo(_helpLabel.BottomAnchor), _activityIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _activityIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _activityIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor) }); }
public MainWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) : base(contentRect, aStyle, bufferingType, deferCreation) { var windowSize = new CGSize(640, 480); var windowLocation = new CGPoint(NSScreen.MainScreen.Frame.Width / 2 - windowSize.Width / 2, NSScreen.MainScreen.Frame.Height / 2 - windowSize.Height / 2); var centerRect = new CGRect(windowLocation, windowSize); Title = "Programmatic window"; ContentView = new NSView(centerRect); var title = new NSTextField { StringValue = "Title your problem", Editable = true, UsesSingleLineMode = true, PlaceholderString = "Title your problem" }; title.AccessibilityLabel = title.PlaceholderString; title.TranslatesAutoresizingMaskIntoConstraints = false; ContentView.AddSubview(title); // There are three ways to set auto layout constraints programmatically. The first is by setting layout anchors // https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html#//apple_ref/doc/uid/TP40010853-CH16-SW5 // Don't forget to set .Active = true on the constraint or it won't show up title.LeadingAnchor.ConstraintEqualToAnchor(ContentView.LeadingAnchor, PADDING).Active = true; title.TrailingAnchor.ConstraintEqualToAnchor(ContentView.TrailingAnchor, -PADDING).Active = true; title.TopAnchor.ConstraintEqualToAnchor(ContentView.TopAnchor, PADDING).Active = true; var scroll = new NSScrollView(new CGRect(0, 0, ContentView.Frame.Width - PADDING - PADDING, 100)); scroll.BorderType = NSBorderType.BezelBorder; scroll.HasHorizontalScroller = false; scroll.HasVerticalScroller = true; var scrollSize = scroll.ContentSize; var description = new NSTextView(new CGRect(0, 0, scrollSize.Width, scrollSize.Height)); description.MinSize = new CGSize(0, scrollSize.Height); description.MaxSize = new CGSize(float.MaxValue, float.MaxValue); description.Editable = true; description.Font = title.Font; description.VerticallyResizable = true; description.HorizontallyResizable = false; description.AutoresizingMask = NSViewResizingMask.WidthSizable; description.TextContainer.Size = new CGSize(scrollSize.Width, float.MaxValue); description.TextContainer.WidthTracksTextView = true; scroll.DocumentView = description; scroll.TranslatesAutoresizingMaskIntoConstraints = false; ContentView.AddSubview(scroll); // The second option is to create NSLayoutConstraints // https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html#//apple_ref/doc/uid/TP40010853-CH16-SW8 ContentView.AddConstraints(new [] { NSLayoutConstraint.Create(scroll, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1, PADDING), NSLayoutConstraint.Create(scroll, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Trailing, 1, -PADDING) }); // Alternatively, you can create the constraints as shown here and set .Active = true, same as with the anchor method above NSLayoutConstraint.Create(scroll, NSLayoutAttribute.Top, NSLayoutRelation.Equal, title, NSLayoutAttribute.Bottom, 1, PADDING).Active = true; title.Activated += (sender, e) => MakeFirstResponder(description); var labelFont = NSFont.LabelFontOfSize(10); var publicLabel = new NSTextField { StringValue = "Your title and description will be public", Editable = false, Bezeled = false, DrawsBackground = false, Selectable = false, Font = labelFont, TranslatesAutoresizingMaskIntoConstraints = false }; ContentView.AddSubview(publicLabel); // You can also use different types of constraints for the same view ContentView.AddConstraints(new [] { NSLayoutConstraint.Create(publicLabel, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, ContentView, NSLayoutAttribute.Leading, 1, 40), NSLayoutConstraint.Create(publicLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Trailing, 1, -PADDING) }); publicLabel.TopAnchor.ConstraintEqualToAnchor(scroll.BottomAnchor, 5).Active = true; var email = new NSTextField { Editable = true, PlaceholderString = "Optional email address" }; email.AccessibilityLabel = email.PlaceholderString; email.TranslatesAutoresizingMaskIntoConstraints = false; ContentView.AddSubview(email); ContentView.AddConstraints(new [] { NSLayoutConstraint.Create(email, NSLayoutAttribute.Top, NSLayoutRelation.Equal, publicLabel, NSLayoutAttribute.Bottom, 1, PADDING) }); // The third option for setting layout constraints is to use Visual Format Language // https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html#//apple_ref/doc/uid/TP40010853-CH16-SW9 string emailFormat = "|-10-[email]-10-|"; var emailViews = NSDictionary.FromObjectAndKey(email, (NSString)"email"); var emailConstraints = NSLayoutConstraint.FromVisualFormat(emailFormat, NSLayoutFormatOptions.None, null, emailViews); NSLayoutConstraint.ActivateConstraints(emailConstraints); var sendButton = new NSButton { Title = "OK" }; sendButton.Activated += (sender, e) => { var alert = new NSAlert { MessageText = "Button pressed" }; alert.AddButton("Okay"); alert.RunModal(); Dispose(); }; sendButton.TranslatesAutoresizingMaskIntoConstraints = false; ContentView.AddSubview(sendButton); ContentView.AddConstraints(new [] { NSLayoutConstraint.Create(sendButton, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Trailing, 1, -PADDING), NSLayoutConstraint.Create(sendButton, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, ContentView, NSLayoutAttribute.Leading, 1, 40) }); //To do vertical constraints with visual format language, start the format string with V:" string sendButtonFormat = "V:[email]-10-[sendButton]-10-|"; var sendButtonViews = NSDictionary.FromObjectsAndKeys(new NSObject [] { email, sendButton }, new NSObject [] { (NSString)"email", (NSString)"sendButton" }); var sendButtonConstraints = NSLayoutConstraint.FromVisualFormat(sendButtonFormat, NSLayoutFormatOptions.None, null, sendButtonViews); NSLayoutConstraint.ActivateConstraints(sendButtonConstraints); email.Activated += (sender, e) => { if (sendButton.Enabled) { MakeFirstResponder(sendButton); } }; bool hasTitle = false; bool hasDescription = false; title.Changed += (sender, e) => { var titleStr = title.StringValue; hasTitle = !string.IsNullOrWhiteSpace(titleStr) && titleStr.Length > 5; sendButton.Enabled = hasTitle && hasDescription; }; description.TextStorage.DidProcessEditing += (sender, e) => { hasDescription = description.TextStorage.Length > 10; sendButton.Enabled = hasTitle && hasDescription; }; }
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) }); }
public override void LoadView() { // Create the views. View = new UIView() { BackgroundColor = ApplicationTheme.BackgroundColor }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _openSwitch = new UISwitch() { Enabled = false }; _openSwitch.On = true; _closedSwitch = new UISwitch() { Enabled = false }; _closedSwitch.On = true; _openLabel = new UILabel(); _closedLabel = new UILabel(); UIStackView openRow = new UIStackView(new UIView[] { _openSwitch, _openLabel }) { TranslatesAutoresizingMaskIntoConstraints = false, LayoutMarginsRelativeArrangement = true, LayoutMargins = new UIEdgeInsets(5, 5, 5, 5), Spacing = 8, Axis = UILayoutConstraintAxis.Horizontal, Distribution = UIStackViewDistribution.Fill }; UIStackView closedRow = new UIStackView(new UIView[] { _closedSwitch, _closedLabel }) { TranslatesAutoresizingMaskIntoConstraints = false, LayoutMarginsRelativeArrangement = true, LayoutMargins = new UIEdgeInsets(5, 5, 5, 5), Spacing = 8, Axis = UILayoutConstraintAxis.Horizontal, Distribution = UIStackViewDistribution.Fill }; _scaleLabel = new UILabel { Text = "Current map scale: 1:", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; // Add the views. View.AddSubviews(_myMapView, openRow, closedRow, _scaleLabel); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(openRow.TopAnchor), openRow.BottomAnchor.ConstraintEqualTo(closedRow.TopAnchor), openRow.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), openRow.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), closedRow.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), closedRow.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), closedRow.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _scaleLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _scaleLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _scaleLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _scaleLabel.HeightAnchor.ConstraintEqualTo(40) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _addButton = new UIBarButtonItem(UIBarButtonSystemItem.Add); _doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done); _saveButton = new UIBarButtonItem(); _saveButton.Title = "Save"; _resetButton = new UIBarButtonItem(); _resetButton.Title = "Reset"; _toolbar = new UIToolbar(); _toolbar.TranslatesAutoresizingMaskIntoConstraints = false; _toolbar.Items = new[] { _addButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _saveButton, _resetButton }; _helpLabel = new UILabel { Text = "Press the '+' button to start.", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; // Add the views. View.AddSubviews(_myMapView, _toolbar, _helpLabel); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(_toolbar.TopAnchor), _toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), _toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _helpLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _helpLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _helpLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _helpLabel.HeightAnchor.ConstraintEqualTo(25) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; UIToolbar topToolbar = new UIToolbar(); topToolbar.TranslatesAutoresizingMaskIntoConstraints = false; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _timeLabel = new UILabel { TextColor = UIColor.Black, TextAlignment = UITextAlignment.Center, TranslatesAutoresizingMaskIntoConstraints = false }; _timeSlider = new UISlider { MinValue = 0, MaxValue = 1, TranslatesAutoresizingMaskIntoConstraints = false }; UIToolbar bottomToolbar = new UIToolbar(); bottomToolbar.TranslatesAutoresizingMaskIntoConstraints = false; bottomToolbar.Items = new[] { new UIBarButtonItem(_timeLabel), new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace) { Width = 0 }, new UIBarButtonItem(_timeSlider) }; UIStackView legendView = new UIStackView(); legendView.TranslatesAutoresizingMaskIntoConstraints = false; legendView.Axis = UILayoutConstraintAxis.Horizontal; legendView.Spacing = 8; UIView redIcon = new UIView(); redIcon.TranslatesAutoresizingMaskIntoConstraints = false; redIcon.BackgroundColor = UIColor.Red; redIcon.WidthAnchor.ConstraintEqualTo(16).Active = true; redIcon.HeightAnchor.ConstraintEqualTo(16).Active = true; redIcon.ClipsToBounds = true; redIcon.Layer.CornerRadius = 8; legendView.AddArrangedSubview(redIcon); UILabel _redLabel = new UILabel { Text = "Offset 10 days", TextColor = UIColor.Red, TranslatesAutoresizingMaskIntoConstraints = false }; legendView.AddArrangedSubview(_redLabel); UIView spacer = new UIView(); spacer.TranslatesAutoresizingMaskIntoConstraints = false; spacer.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultLow, UILayoutConstraintAxis.Horizontal); legendView.AddArrangedSubview(spacer); UIView blueIcon = new UIView(); blueIcon.BackgroundColor = UIColor.Blue; blueIcon.TranslatesAutoresizingMaskIntoConstraints = false; blueIcon.WidthAnchor.ConstraintEqualTo(16).Active = true; blueIcon.HeightAnchor.ConstraintEqualTo(16).Active = true; blueIcon.ClipsToBounds = true; blueIcon.Layer.CornerRadius = 8; legendView.AddArrangedSubview(blueIcon); UILabel _blueLabel = new UILabel { Text = "No offset", TextColor = UIColor.Blue, TranslatesAutoresizingMaskIntoConstraints = false }; legendView.AddArrangedSubview(_blueLabel); // Add the views. View.AddSubviews(topToolbar, _myMapView, bottomToolbar); topToolbar.AddSubview(legendView); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { topToolbar.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), topToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), topToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.TopAnchor.ConstraintEqualTo(topToolbar.BottomAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(bottomToolbar.TopAnchor), bottomToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), bottomToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), bottomToolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), legendView.LeftAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.LeftAnchor, 8), legendView.RightAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.RightAnchor, -8), legendView.TopAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.TopAnchor, 8), legendView.BottomAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.BottomAnchor, -8), redIcon.CenterYAnchor.ConstraintEqualTo(blueIcon.CenterYAnchor), blueIcon.CenterYAnchor.ConstraintEqualTo(topToolbar.CenterYAnchor), _timeLabel.WidthAnchor.ConstraintEqualTo(150), _timeSlider.WidthAnchor.ConstraintEqualTo(600), }); }
public override void LoadView() { // Create the views. View = new UIView() { BackgroundColor = UIColor.White }; UIScrollView scrollView = new UIScrollView(); scrollView.TranslatesAutoresizingMaskIntoConstraints = false; View.AddSubviews(scrollView); NSLayoutConstraint.ActivateConstraints(new[] { scrollView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), scrollView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor), scrollView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor), scrollView.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), }); UIStackView buttonContainer = new UIStackView(); buttonContainer.Axis = UILayoutConstraintAxis.Vertical; buttonContainer.TranslatesAutoresizingMaskIntoConstraints = false; buttonContainer.Distribution = UIStackViewDistribution.Fill; buttonContainer.Alignment = UIStackViewAlignment.Top; buttonContainer.Spacing = 5; buttonContainer.LayoutMarginsRelativeArrangement = true; buttonContainer.DirectionalLayoutMargins = new NSDirectionalEdgeInsets(10, 10, 10, 0); UILabel barrierLabel = new UILabel() { Text = "Include barriers ", TranslatesAutoresizingMaskIntoConstraints = false }; _barrierSwitch = new UISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, On = true }; buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { barrierLabel, _barrierSwitch })); UILabel containerLabel = new UILabel() { Text = "Include containers", TranslatesAutoresizingMaskIntoConstraints = false }; _containerSwitch = new UISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, On = true }; buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { containerLabel, _containerSwitch })); UILabel helpLabel = new UILabel() { Text = "Example barrier condition for this data: 'Transformer Load' Equal '15'", TranslatesAutoresizingMaskIntoConstraints = false, Lines = 0 }; buttonContainer.AddArrangedSubview(helpLabel); UILabel conditionTitleLabel = new UILabel() { Text = "Barrier Condition:", TranslatesAutoresizingMaskIntoConstraints = false, Lines = 0, MinimumFontSize = (nfloat)(helpLabel.MinimumFontSize * 1.5) }; buttonContainer.AddArrangedSubview(conditionTitleLabel); _attributeButton = new UIButton() { TranslatesAutoresizingMaskIntoConstraints = false }; _attributeButton.SetTitle("Attribute", UIControlState.Normal); _attributeButton.SetTitleColor(View.TintColor, UIControlState.Normal); _comparisonButton = new UIButton() { TranslatesAutoresizingMaskIntoConstraints = false }; _comparisonButton.SetTitle("Comparison", UIControlState.Normal); _comparisonButton.SetTitleColor(View.TintColor, UIControlState.Normal); _valueButton = new UIButton() { TranslatesAutoresizingMaskIntoConstraints = false }; _valueButton.SetTitle("Value", UIControlState.Normal); _valueButton.SetTitleColor(View.TintColor, UIControlState.Normal); buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { _attributeButton, _comparisonButton, _valueButton })); _addButton = new UIButton() { TranslatesAutoresizingMaskIntoConstraints = false }; _addButton.SetTitle("Add barrier condition", UIControlState.Normal); _addButton.SetTitleColor(View.TintColor, UIControlState.Normal); buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { _addButton })); _expressionLabel = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "", Lines = 0 }; buttonContainer.AddArrangedSubview(_expressionLabel); _traceButton = new UIButton() { TranslatesAutoresizingMaskIntoConstraints = false }; _traceButton.SetTitle("Trace", UIControlState.Normal); _traceButton.SetTitleColor(View.TintColor, UIControlState.Normal); _resetButton = new UIButton() { TranslatesAutoresizingMaskIntoConstraints = false }; _resetButton.SetTitle("Reset", UIControlState.Normal); _resetButton.SetTitleColor(View.TintColor, UIControlState.Normal); buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { _traceButton, _resetButton })); scrollView.AddSubview(buttonContainer); NSLayoutConstraint.ActivateConstraints(new[] { buttonContainer.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor), buttonContainer.LeadingAnchor.ConstraintEqualTo(scrollView.LeadingAnchor), buttonContainer.TrailingAnchor.ConstraintEqualTo(scrollView.TrailingAnchor), buttonContainer.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor), buttonContainer.WidthAnchor.ConstraintEqualTo(scrollView.WidthAnchor), }); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.White; titleLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Title", Font = UIFont.PreferredTitle1, TextAlignment = UITextAlignment.Center, }; plusImage = new UIImageView { TranslatesAutoresizingMaskIntoConstraints = false, Image = UIImage.FromBundle("Plus"), ContentMode = UIViewContentMode.ScaleAspectFit, }; text1Label = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Subtitle", Font = UIFont.PreferredTitle2, TextAlignment = UITextAlignment.Left, }; text2Label = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Very long text", Font = UIFont.PreferredBody, TextAlignment = UITextAlignment.Left, }; text3Label = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Text", Font = UIFont.PreferredFootnote, TextAlignment = UITextAlignment.Left, }; button = new UIButton(UIButtonType.RoundedRect) { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = UIColor.LightGray, }; button.SetTitle("Button", UIControlState.Normal); slider = new UISlider { TranslatesAutoresizingMaskIntoConstraints = false, MinValue = 0, MaxValue = 1, Value = 0.5f, }; View.AddSubviews(titleLabel, plusImage, text1Label, text2Label, text3Label, button, slider); var guide = View.SafeAreaLayoutGuide; NSLayoutConstraint.ActivateConstraints(new[] { titleLabel.TopAnchor.ConstraintEqualTo(guide.TopAnchor, 16), titleLabel.LeadingAnchor.ConstraintEqualTo(guide.LeadingAnchor, 8), titleLabel.TrailingAnchor.ConstraintEqualTo(guide.TrailingAnchor, -8), plusImage.TopAnchor.ConstraintEqualTo(titleLabel.BottomAnchor, 16), plusImage.LeadingAnchor.ConstraintEqualTo(guide.LeadingAnchor, 8), plusImage.WidthAnchor.ConstraintEqualTo(40), plusImage.BottomAnchor.ConstraintEqualTo(slider.BottomAnchor), text1Label.LeadingAnchor.ConstraintEqualTo(plusImage.TrailingAnchor, 16), text2Label.LeadingAnchor.ConstraintEqualTo(plusImage.TrailingAnchor, 16), text3Label.LeadingAnchor.ConstraintEqualTo(plusImage.TrailingAnchor, 16), text1Label.TopAnchor.ConstraintEqualTo(plusImage.TopAnchor), text2Label.TopAnchor.ConstraintEqualTo(text1Label.BottomAnchor, 8), text3Label.TopAnchor.ConstraintEqualTo(text2Label.BottomAnchor, 8), button.LeadingAnchor.ConstraintGreaterThanOrEqualTo(text1Label.TrailingAnchor, 16), button.LeadingAnchor.ConstraintGreaterThanOrEqualTo(text2Label.TrailingAnchor, 16), button.LeadingAnchor.ConstraintGreaterThanOrEqualTo(text3Label.TrailingAnchor, 16), button.WidthAnchor.ConstraintGreaterThanOrEqualTo(60), button.TopAnchor.ConstraintEqualTo(text1Label.TopAnchor), button.BottomAnchor.ConstraintEqualTo(text3Label.BottomAnchor), slider.TopAnchor.ConstraintEqualTo(text3Label.BottomAnchor, 8), slider.LeadingAnchor.ConstraintEqualTo(text1Label.LeadingAnchor), slider.TrailingAnchor.ConstraintEqualTo(button.TrailingAnchor), }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _takeMapOfflineButton = new UIBarButtonItem(); _takeMapOfflineButton.Title = "Generate offline map"; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _takeMapOfflineButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) }; _statusLabel = new UILabel { Text = "Use the button to take the map offline.", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; _loadingIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); _loadingIndicator.TranslatesAutoresizingMaskIntoConstraints = false; _loadingIndicator.BackgroundColor = UIColor.FromWhiteAlpha(0, .6f); // Add the views. View.AddSubviews(_myMapView, toolbar, _loadingIndicator, _statusLabel); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), _statusLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor), _statusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _statusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _statusLabel.HeightAnchor.ConstraintEqualTo(40), _loadingIndicator.TopAnchor.ConstraintEqualTo(_statusLabel.BottomAnchor), _loadingIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), _loadingIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _loadingIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = ApplicationTheme.BackgroundColor }; _myMapView = new MapView(); _myMapView.TranslatesAutoresizingMaskIntoConstraints = false; _screenshotButton = new UIBarButtonItem(); _screenshotButton.Title = "Take screenshot"; _closePreviewButton = new UIBarButtonItem(); _closePreviewButton.Title = "Close preview"; _closePreviewButton.Enabled = false; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { _screenshotButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _closePreviewButton }; _overlayImageView = new UIImageView(); _overlayImageView.TranslatesAutoresizingMaskIntoConstraints = false; _overlayImageView.ContentMode = UIViewContentMode.ScaleAspectFit; _overlayView = new UIView() { BackgroundColor = ApplicationTheme.BackgroundColor }; _overlayView.TranslatesAutoresizingMaskIntoConstraints = false; _overlayView.BackgroundColor = ApplicationTheme.BackgroundColor; _overlayView.Layer.BorderColor = ApplicationTheme.ForegroundColor.CGColor; _overlayView.Layer.BorderWidth = 2; _overlayView.Hidden = true; // Add the views. _overlayView.AddSubview(_overlayImageView); View.AddSubviews(_myMapView, toolbar, _overlayView); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _overlayView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor, 0.9f), _overlayView.HeightAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.HeightAnchor, 0.8f), _overlayView.CenterXAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.CenterXAnchor), _overlayView.CenterYAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.CenterYAnchor), _overlayImageView.LeadingAnchor.ConstraintEqualTo(_overlayView.LeadingAnchor), _overlayImageView.TrailingAnchor.ConstraintEqualTo(_overlayView.TrailingAnchor), _overlayImageView.TopAnchor.ConstraintEqualTo(_overlayView.TopAnchor), _overlayImageView.BottomAnchor.ConstraintEqualTo(_overlayView.BottomAnchor) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; // Create the scene view. _mySceneView = new SceneView { TranslatesAutoresizingMaskIntoConstraints = false }; // Create the toolbars. _buttonToolbar = new UIToolbar { TranslatesAutoresizingMaskIntoConstraints = false }; // Create the opacity items. var opacityLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Opacity" }; _opacitySlider = new UISlider { TranslatesAutoresizingMaskIntoConstraints = false, MinValue = 0, MaxValue = 1, Value = 1 }; // Add the opacity items to a stackview. var stackView = new UIStackView() { TranslatesAutoresizingMaskIntoConstraints = false, Distribution = UIStackViewDistribution.Fill, Alignment = UIStackViewAlignment.Center, Axis = UILayoutConstraintAxis.Horizontal, Spacing = 10, LayoutMargins = new UIEdgeInsets(5, 5, 5, 5), LayoutMarginsRelativeArrangement = true, }; stackView.AddArrangedSubview(opacityLabel); stackView.AddArrangedSubview(_opacitySlider); // Create the buttons. _pauseButton = new UIBarButtonItem { Title = "Stop" }; _speedButton = new UIBarButtonItem { Title = "Slow" }; // Add the buttons to a toolbar. _buttonToolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _pauseButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _speedButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; // Add the views. View.AddSubviews(_mySceneView, stackView, _buttonToolbar); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _mySceneView.BottomAnchor.ConstraintEqualTo(stackView.TopAnchor), _mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), stackView.TopAnchor.ConstraintEqualTo(_mySceneView.BottomAnchor), stackView.BottomAnchor.ConstraintEqualTo(_buttonToolbar.TopAnchor), stackView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), stackView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _buttonToolbar.TopAnchor.ConstraintEqualTo(stackView.BottomAnchor), _buttonToolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), _buttonToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _buttonToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), }); }
public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); CameraButton.Layer.CornerRadius = CameraButton.Layer.Frame.Size.Width / 2; CameraButton.BackgroundColor = UIColor.FromRGB(0x5A, 0x86, 0x22); // 5A8622 dark-green CameraButton.SetTitleColor(UIColor.FromRGB(0xCF, 0xEF, 0xa7), UIControlState.Normal); // CFEFA7 light-green CameraButton.ClipsToBounds = true; //CameraButton.setImage(UIImage(named: "your-image"), for: .normal) CameraButton.TranslatesAutoresizingMaskIntoConstraints = false; GalleryButton.Layer.CornerRadius = GalleryButton.Layer.Frame.Size.Width / 2; GalleryButton.BackgroundColor = UIColor.FromRGB(0x5A, 0x86, 0x22); // 5A8622 dark-green GalleryButton.SetTitleColor(UIColor.FromRGB(0xCF, 0xEF, 0xa7), UIControlState.Normal); // CFEFA7 light-green GalleryButton.ClipsToBounds = true; //GalleryButton.setImage(UIImage(named: "your-image"), for: .normal) GalleryButton.TranslatesAutoresizingMaskIntoConstraints = false; CloseButton.Layer.CornerRadius = CloseButton.Layer.Frame.Size.Width / 2; CloseButton.BackgroundColor = UIColor.FromRGB(0x5A, 0x86, 0x22); // 5A8622 dark-green CloseButton.SetTitleColor(UIColor.FromRGB(0xCF, 0xEF, 0xa7), UIControlState.Normal); // CFEFA7 light-green CloseButton.ClipsToBounds = true; //CloseButton.setImage(UIImage(named: "your-image"), for: .normal) CloseButton.TranslatesAutoresizingMaskIntoConstraints = false; SaveButton.Layer.CornerRadius = SaveButton.Layer.Frame.Size.Width / 2; SaveButton.BackgroundColor = UIColor.FromRGB(0x5A, 0x86, 0x22); // 5A8622 dark-green SaveButton.SetTitleColor(UIColor.FromRGB(0xCF, 0xEF, 0xa7), UIControlState.Normal); // CFEFA7 light-green SaveButton.ClipsToBounds = true; //SaveButton.setImage(UIImage(named: "your-image"), for: .normal) SaveButton.TranslatesAutoresizingMaskIntoConstraints = false; ClassificationLabel.TranslatesAutoresizingMaskIntoConstraints = false; var safeGuide = View.SafeAreaLayoutGuide; NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { CloseButton.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor, -23), CloseButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13), CloseButton.WidthAnchor.ConstraintEqualTo(60), CloseButton.HeightAnchor.ConstraintEqualTo(60) }); NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { CameraButton.TrailingAnchor.ConstraintEqualTo(CloseButton.LeadingAnchor, -23), CameraButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13), CameraButton.WidthAnchor.ConstraintEqualTo(60), CameraButton.HeightAnchor.ConstraintEqualTo(60) }); NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { GalleryButton.TrailingAnchor.ConstraintEqualTo(CameraButton.LeadingAnchor, -23), GalleryButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13), GalleryButton.WidthAnchor.ConstraintEqualTo(60), GalleryButton.HeightAnchor.ConstraintEqualTo(60) }); NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { SaveButton.TrailingAnchor.ConstraintEqualTo(GalleryButton.LeadingAnchor, -23), SaveButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13), SaveButton.WidthAnchor.ConstraintEqualTo(60), SaveButton.HeightAnchor.ConstraintEqualTo(60) }); var marginGuide = View.LayoutMarginsGuide; NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { ClassificationLabel.LeadingAnchor.ConstraintEqualTo(marginGuide.LeadingAnchor), ClassificationLabel.TrailingAnchor.ConstraintEqualTo(marginGuide.TrailingAnchor), ClassificationLabel.BottomAnchor.ConstraintEqualTo(CloseButton.TopAnchor, -13), ClassificationLabel.HeightAnchor.ConstraintEqualTo(120) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _mySceneView = new SceneView(); _mySceneView.TranslatesAutoresizingMaskIntoConstraints = false; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; _playButton = new UIBarButtonItem(UIBarButtonSystemItem.Play, Play_Clicked) { Enabled = false }; _pauseButton = new UIBarButtonItem(UIBarButtonSystemItem.Pause, Pause_Clicked) { Enabled = false }; _resetButton = new UIBarButtonItem(UIBarButtonSystemItem.Refresh, Reset_Clicked) { Enabled = false }; toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _playButton, _pauseButton, _resetButton }; UILabel helpLabel = new UILabel { Text = "Use the buttons to play the tour. Contains audio. 🎧", AdjustsFontSizeToFitWidth = true, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f), TextColor = UIColor.White, Lines = 1, TranslatesAutoresizingMaskIntoConstraints = false }; _loadingIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge) { TranslatesAutoresizingMaskIntoConstraints = false, HidesWhenStopped = true, BackgroundColor = UIColor.FromWhiteAlpha(0, .6f) }; _loadingIndicator.StartAnimating(); // Add the views. View.AddSubviews(_mySceneView, toolbar, helpLabel, _loadingIndicator); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _mySceneView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), _mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor), helpLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), helpLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), helpLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), helpLabel.HeightAnchor.ConstraintEqualTo(40), _loadingIndicator.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _loadingIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _loadingIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _loadingIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor) }); }
public override void LoadView() { // Create the views. View = new UIView { BackgroundColor = UIColor.White }; _mySceneView = new SceneView(); _mySceneView.TranslatesAutoresizingMaskIntoConstraints = false; UILabel opacityLabel = new UILabel() { Text = "Opacity ", TranslatesAutoresizingMaskIntoConstraints = false }; _slider = new UISlider() { MinValue = 0, MaxValue = 255, TranslatesAutoresizingMaskIntoConstraints = false }; _valueLabel = new UILabel() { Text = "255", TranslatesAutoresizingMaskIntoConstraints = false }; UIToolbar toolbar = new UIToolbar(); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.Items = new[] { new UIBarButtonItem { CustomView = opacityLabel }, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem { CustomView = _slider, Width = 200 }, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem { CustomView = _valueLabel } }; // Add the views. View.AddSubviews(_mySceneView, toolbar); // Lay out the views. NSLayoutConstraint.ActivateConstraints(new[] { _mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor), _mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _mySceneView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor), toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor) }); }