当前位置: 首页>>代码示例>>C#>>正文


C# UIToolbar.SetItems方法代码示例

本文整理汇总了C#中UIToolbar.SetItems方法的典型用法代码示例。如果您正苦于以下问题:C# UIToolbar.SetItems方法的具体用法?C# UIToolbar.SetItems怎么用?C# UIToolbar.SetItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIToolbar的用法示例。


在下文中一共展示了UIToolbar.SetItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UIMonthTextField

        public UIMonthTextField(IntPtr handle)
            : base(handle)
        {
            monthPicker = new MonthPickerView();

            // Setup the toolbar
            UIToolbar toolbar = new UIToolbar();
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar
            UIBarButtonItem unitDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                this.Text = monthPicker.SelectedDate.ToString(this.format);
                this._currentDate = monthPicker.SelectedDate;
                this.ResignFirstResponder();
            });

            // Create flexible space
            UIBarButtonItem unitFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            // Add button and unitFlexible space to the toolbar
            toolbar.SetItems(new UIBarButtonItem[]{unitFlex, unitDoneButton}, true);

            // Tell the textbox to use the picker for input
            this.InputView = monthPicker;

            // Display the toolbar over the pickers
            this.InputAccessoryView = toolbar;
        }
开发者ID:bertouttier,项目名称:ExpenseApp-Mono,代码行数:30,代码来源:UIMonthTextField.cs

示例2: ViewDidLoad

	public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			UIDatePicker datePicker = new UIDatePicker ();
			datePicker.Mode = UIDatePickerMode.Date;
			datePicker.BackgroundColor = UIColor.White;

			datePicker.MinimumDate = DateTime.Today.AddDays(-7);
			datePicker.MaximumDate = DateTime.Today.AddDays(7);

			UIToolbar toolbar = new UIToolbar();
			toolbar.BarStyle = UIBarStyle.Default;
			toolbar.Translucent = true;
			toolbar.SizeToFit();

			UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
				(s, e) => {
					DateTime dateTime = DateTime.SpecifyKind(datePicker.Date, DateTimeKind.Unspecified);
					this.textField.Text = dateTime.ToString("MM-dd-yyyy");
					this.textField.ResignFirstResponder();
				});
			toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true);

			this.textField.InputAccessoryView = toolbar;
			
			textField.InputView = datePicker;
		}
开发者ID:mhalkovitch,项目名称:Xamarim,代码行数:28,代码来源:DatePickerExampleViewController.cs

示例3: UiSetKeyboardEditorWithCloseButton

        public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType)
        {
            var toolbar = new UIToolbar
            {
                BarStyle = UIBarStyle.Black,
                Translucent = true,
            };
            txt.KeyboardType = keyboardType;
            toolbar.SizeToFit();

            var text = new UITextView(new CGRect(0, 0, 200, 32))
            {
                ContentInset = UIEdgeInsets.Zero,
                KeyboardType = keyboardType,
                Text = txt.Text,
                UserInteractionEnabled = true
            };
            text.Layer.CornerRadius = 4f;
            text.BecomeFirstResponder();

            var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
                                 (s, e) =>
                {
                    text.ResignFirstResponder();
                    txt.ResignFirstResponder();
                });

            toolbar.UserInteractionEnabled = true;
            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            txt.InputAccessoryView = toolbar;
        }
开发者ID:nodoid,项目名称:mvvmlight1,代码行数:32,代码来源:UIUtils.cs

示例4: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			string selectedColor = "";

			PickerModel model = new PickerModel();
			model.ValueChanged += (sender, e) => {
				selectedColor = model.SelectedItem;
			};

			UIPickerView picker = new UIPickerView();
			picker.ShowSelectionIndicator = false;
			picker.BackgroundColor = UIColor.White;
			picker.Model = model;

			this.color.Text = model.SelectedItem;

			UIToolbar toolbar = new UIToolbar();
			toolbar.BarStyle = UIBarStyle.Default;
			toolbar.Translucent = true;
			toolbar.SizeToFit();

			UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
				(s, e) => {
					this.color.Text = selectedColor;
					this.color.ResignFirstResponder();
				});
			toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true);

			this.color.InputView = picker;

			this.color.InputAccessoryView = toolbar;
		}
开发者ID:mhalkovitch,项目名称:Xamarim,代码行数:34,代码来源:PickerExampleViewController.cs

示例5: UICurrencyTextField

        public UICurrencyTextField(IntPtr handle)
            : base(handle)
        {
            unitPicker = new CurrencyPickerView();

            // Setup the unitToolbar
            UIToolbar unitToolbar = new UIToolbar();
            unitToolbar.BarStyle = UIBarStyle.Black;
            unitToolbar.Translucent = true;
            unitToolbar.SizeToFit();

            // Create a 'done' button for the unitToolbar
            UIBarButtonItem unitDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                base.Text = unitPicker.SelectedValue;
                this.selectedIndex = unitPicker.SelectedKey;
                this.ResignFirstResponder();
            });

            // Create flexible space
            UIBarButtonItem unitFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            // Add button and unitFlexible space to the unitToolbar
            unitToolbar.SetItems(new UIBarButtonItem[]{unitFlex, unitDoneButton}, true);

            // Tell the textbox to use the picker for input
            this.InputView = unitPicker;

            // Display the toolbar over the pickers
            this.InputAccessoryView = unitToolbar;
        }
开发者ID:bertouttier,项目名称:ExpenseApp-Mono,代码行数:30,代码来源:UICurrencyTextField.cs

示例6: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			this.NavigationItem.HidesBackButton = true;
			if(isFrom == "")
				setAccountResponse (Constant.selectedAffialte );

			Appdata.setButtonBorder (btnSave);
			btnSave.BackgroundColor = Appdata.buttonBackgroundColor;

			if (UserInterfaceIsPhone)
				SetLayoytIPhone ();
			else
				SetLayoytIPad ();
			
			UIToolbar toolbar = new UIToolbar();
			toolbar.BarStyle = UIBarStyle.Default;
			toolbar.Translucent = true;
			toolbar.SizeToFit();

			// Create a 'done' button for the toolbar and add it to the toolbar
			UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
				(s, e) => {
					Console.WriteLine ("Calling Done!");
				});
			toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true);
		}
开发者ID:kumaralg2,项目名称:Jan28-TS,代码行数:28,代码来源:TSAccountBasicView.cs

示例7: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a variable to hold the yOffset where the MapView control should start
            var yOffset = 60;

            // Create a new MapView control and provide its location coordinates on the frame
            MapView myMapView = new MapView();
            myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset);

            // Create a new Map instance with the basemap  
            var myBasemap = Basemap.CreateStreets();
            Map myMap = new Map(myBasemap);

            // Assign the Map to the MapView
            myMapView.Map = myMap;

            // Create a label to display the MapView rotation value
            UILabel rotationLabel = new UILabel();
            rotationLabel.Frame = new CoreGraphics.CGRect(View.Bounds.Width - 60, 8, View.Bounds.Width, 24);
            rotationLabel.Text = string.Format("{0:0}°", myMapView.MapRotation);

            // Create a slider to control the MapView rotation
            UISlider rotationSlider = new UISlider()
            {
                MinValue = 0,
                MaxValue = 360,
                Value = (float)myMapView.MapRotation
            };
            rotationSlider.Frame = new CoreGraphics.CGRect(10, 8, View.Bounds.Width - 100, 24);
            rotationSlider.ValueChanged += (Object s, EventArgs e) =>
            {
                myMapView.SetViewpointRotationAsync(rotationSlider.Value);
                rotationLabel.Text = string.Format("{0:0}°", rotationSlider.Value);
            };

            // Create a UIBarButtonItem where its view is the rotation slider
            UIBarButtonItem barButtonSlider = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            barButtonSlider.CustomView = rotationSlider;

            // Create a UIBarButtonItem where its view is the rotation label
            UIBarButtonItem barButtonLabel = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            barButtonLabel.CustomView = rotationLabel;

            // Create a toolbar on the bottom of the display 
            UIToolbar toolbar = new UIToolbar();
            toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height);
            toolbar.AutosizesSubviews = true;

            // Add the bar button items to an array of UIBarButtonItems
            UIBarButtonItem[] barButtonItems = new UIBarButtonItem[] { barButtonSlider, barButtonLabel };

            // Add the UIBarButtonItems array to the toolbar
            toolbar.SetItems(barButtonItems, true);

            View.AddSubviews(myMapView, toolbar);
        }
开发者ID:Esri,项目名称:arcgis-runtime-samples-dotnet,代码行数:58,代码来源:MapRotation.cs

示例8: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			Title = "Programmatic Toolbar";

			// set the background color of the view to white
			View.BackgroundColor = UIColor.White;

			// new up the toolbar
			float toolbarHeight = 44;
			toolbar = new UIToolbar (new CGRect (0
					, View.Frame.Height - NavigationController.NavigationBar.Frame.Height
					, View.Frame.Width, toolbarHeight));
			toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;


			// button one
			string buttonTitle = "One";
			UIBarButtonItem btnOne = new UIBarButtonItem (buttonTitle, UIBarButtonItemStyle.Bordered, null);
			btnOne.Clicked += (s, e) => {
				new UIAlertView ("click!", "btnOne clicked", null, "OK", null).Show ();
			};

			// fixed width
			UIBarButtonItem fixedWidth = new UIBarButtonItem (UIBarButtonSystemItem.FixedSpace) { Width = 25 };

			// button two
			UIBarButtonItem btnTwo = new UIBarButtonItem ("second", UIBarButtonItemStyle.Bordered, null);

			// flexible width space
			UIBarButtonItem flexibleWidth = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);

			// button three
			UIBarButtonItem btnThree = new UIBarButtonItem ("3", UIBarButtonItemStyle.Bordered, null);

			// button four
			UIBarButtonItem btnFour = new UIBarButtonItem ("another!", UIBarButtonItemStyle.Bordered, null);

			// create the items array
			UIBarButtonItem[] items = new UIBarButtonItem[] {
				btnOne, fixedWidth, btnTwo, flexibleWidth, btnThree, btnFour
			};

			// add the items to the toolbar
			toolbar.SetItems (items, false);

			// add the toolbar to the page
			View.AddSubview (toolbar);
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:50,代码来源:ProgrammaticToolbar_Controller.cs

示例9: SetKeyboardEditorWithCloseButton

        public static void SetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType     keyboardType, string closeButtonText = "Done")
        {
            UIToolbar toolbar = new UIToolbar ();
            txt.KeyboardType = keyboardType;
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();
            UIBarButtonItem doneButton = new UIBarButtonItem (closeButtonText, UIBarButtonItemStyle.Done,
                                                              (s, e) => {
                txt.ResignFirstResponder ();
            });
            toolbar.SetItems (new UIBarButtonItem[]{doneButton}, true);

            txt.InputAccessoryView = toolbar;
        }
开发者ID:eiu165,项目名称:checklist,代码行数:15,代码来源:WebServiceScreen.cs

示例10: CreateAccessoryToolbar

        public static UIToolbar CreateAccessoryToolbar(Action doneHandler)
        {
            nfloat width = UIScreen.MainScreen.Bounds.Width;
              UIToolbar uIToolbar = new UIToolbar (new CGRect (0, 0, width, 44))
              {
            BarTintColor = Colors.TabBarBackground.ToUIColor(),
            Translucent = false
              };

              UIBarButtonItem uIBarButtonSpace = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
              UIBarButtonItem uIBarButtonDone = new UIBarButtonItem (UIBarButtonSystemItem.Done, (sender, e) => doneHandler());
              uIToolbar.SetItems (new UIBarButtonItem[]
            {
              uIBarButtonSpace,
              uIBarButtonDone
            }, false);

              return uIToolbar;
        }
开发者ID:anthonylowther21,项目名称:DebtCalculator,代码行数:19,代码来源:KeyboardInputAccessoryHelper.cs

示例11: UIDateTextField

        public UIDateTextField(IntPtr handle)
            : base(handle)
        {
            datePicker = new UIDatePicker();

            dateFormatter = new NSDateFormatter();
            dateFormatter.DateStyle = NSDateFormatterStyle.Long;

            // Set up the date picker
            datePicker.Mode = UIDatePickerMode.Date;
            datePicker.MinimumDate = DateTime.Today.AddMonths (-2);
            datePicker.MaximumDate = DateTime.Today;

            datePicker.ValueChanged += (s, e) => {
                this.Text = dateFormatter.ToString((s as UIDatePicker).Date);
                this._currentDate = DateTime.SpecifyKind((s as UIDatePicker).Date, DateTimeKind.Unspecified);
            };

            // Setup the dateToolbar
            UIToolbar dateToolbar = new UIToolbar();
            dateToolbar.BarStyle = UIBarStyle.Black;
            dateToolbar.Translucent = true;
            dateToolbar.SizeToFit();

            // Create a 'done' button for the dateToolbar
            UIBarButtonItem dateDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                this.ResignFirstResponder();
            });

            // Create flexible space
            UIBarButtonItem dateFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            // Add button and dateFlexible space to the dateToolbar
            dateToolbar.SetItems(new UIBarButtonItem[]{dateFlex, dateDoneButton}, true);

            this.InputView = datePicker;

            this.InputAccessoryView = dateToolbar;
        }
开发者ID:bertouttier,项目名称:ExpenseApp-Mono,代码行数:39,代码来源:UIDateTextField.cs

示例12: SetupToolbarOnKeyboard

        public void SetupToolbarOnKeyboard(UITextView txt)
        {
            UIToolbar toolbar = new UIToolbar ();
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();
            UIBarButtonItem doneButton = new UIBarButtonItem ("Close", UIBarButtonItemStyle.Done,
                                                              (s, e) => {
                txt.ResignFirstResponder ();
            });
            doneButton.TintColor = UIColor.Gray;

            UIBarButtonItem goButton = new UIBarButtonItem ("Run", UIBarButtonItemStyle.Done,
                                                              (s, e) => {

                txt.ResignFirstResponder ();
                OnRun ();
            });

            toolbar.SetItems (new UIBarButtonItem[]{doneButton, goButton}, true);

            txt.InputAccessoryView = toolbar;
        }
开发者ID:JackFong,项目名称:NLuaBox,代码行数:23,代码来源:NLuaSampleViewController.cs

示例13: DatePickerView

        public DatePickerView()
        {
            Frame=new RectangleF (0f, 0f, 100f*Device.screenWidthP,260f);

            toolbar = new UIToolbar(RectangleF.Empty);
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.UserInteractionEnabled = true;
            toolbar.SizeToFit();

            cancelBtn = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, delegate
                {
                    if(cancelBtnClick!=null)
                    {
                        cancelBtnClick(this,EventArgs.Empty);
                    }
                });
            flexibleSpaceBtn = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
            doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
                {
                    if(doneBtnClick!=null)
                    {
                        doneBtnClick(this,EventArgs.Empty);
                    }
                });
            itemsBtn = new UIBarButtonItem[] { cancelBtn, flexibleSpaceBtn, doneBtn };
            toolbar.SetItems(itemsBtn, true);
            Add (toolbar);

            datePicker = new UIDatePicker(new RectangleF(0f,44f,100f*Device.screenWidthP,216f));
            datePicker.Mode = UIDatePickerMode.Date;
            datePicker.MaximumDate = NSDate.Now;
            datePicker.TimeZone = NSTimeZone.LocalTimeZone;
            datePicker.UserInteractionEnabled = true;
            datePicker.BackgroundColor = UIColor.White;
            Add (datePicker);
        }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:37,代码来源:DatePickerView.cs

示例14: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var space = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            var btnClose = new UIBarButtonItem();
            btnClose.Image = UIImage.FromFile("close.png");
            btnClose.Clicked += delegate {
                DismissViewController(true, null);
            };

            var toolBarTitle = new UILabel(new RectangleF(0, 0, View.Bounds.Width, 44));
            toolBarTitle.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            toolBarTitle.BackgroundColor = UIColor.Clear;
            toolBarTitle.TextColor = UIColor.White;
            toolBarTitle.TextAlignment = UITextAlignment.Center;
            toolBarTitle.Text = "Thumbs".t();

            var toolBar = new UIToolbar(new RectangleF(0, 0, View.Bounds.Width, 44));
            toolBar.BarStyle = UIBarStyle.Black;
            toolBar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            toolBar.SetItems(new [] { space, btnClose }, false);
            toolBar.AddSubview(toolBarTitle);
            View.AddSubview(toolBar);

            _thumbsViewContainer = new UIView(new RectangleF(0, 44, View.Bounds.Width, View.Bounds.Height - 85));
            _thumbsViewContainer.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            _thumbsViewContainer.BackgroundColor = UIColor.Gray;
            View.AddSubview(_thumbsViewContainer);

            _thumbsPageControl = new UIPageControl(new RectangleF(0, View.Bounds.Height - 30, View.Bounds.Width, 20));
            _thumbsPageControl.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
            _thumbsPageControl.ValueChanged += delegate {
                createThumbsPage(_thumbsPageControl.CurrentPage);
            };
            View.AddSubview(_thumbsPageControl);
        }
开发者ID:phantomlight,项目名称:mTouch-PDFReader,代码行数:37,代码来源:ThumbsVC.cs

示例15: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			SizeF containerSize = View.Bounds.Size;
			
			mainMapView = new MKMapView () {
				UserInteractionEnabled = true,
				Delegate = new MapDelegate (),
				ScrollEnabled = true,
			};
			
			var toolbar = new UIToolbar () {
				AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth,
			};
			toolbar.SizeToFit ();
			SizeF toolbarSize = toolbar.Bounds.Size;
			
			toolbar.Frame = new RectangleF (0, containerSize.Height - toolbarSize.Height, containerSize.Width, toolbarSize.Height);
			mainMapView.Frame = new RectangleF (0, 0, containerSize.Width, containerSize.Height - toolbarSize.Height);
			
			var resetButton = new UIBarButtonItem ("Reset", UIBarButtonItemStyle.Bordered, removePins);
			var flexibleSpace = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null, null);
			var share = new UIBarButtonItem ("Log", UIBarButtonItemStyle.Bordered, tappedShare);
			
			View.AddSubview (mainMapView);
			View.AddSubview (toolbar);
			
			toolbar.SetItems (new UIBarButtonItem [] {
				resetButton,
				flexibleSpace,
				share
			}, true);
			
			setUpGesture ();
			itemsArray = new List<MyAnnotation> ();
			
		}
开发者ID:robertgreen,项目名称:monotouch-samples,代码行数:37,代码来源:RegionDefinerViewController.cs


注:本文中的UIToolbar.SetItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。