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


C# UIToolbar.SizeToFit方法代码示例

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


在下文中一共展示了UIToolbar.SizeToFit方法的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: 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

示例4: 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

示例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 ();

			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

示例7: GetCell

		public override UITableViewCell GetCell (UITableView tv)
		{
			Value = FormatDate (DateValue);
			EntryElementCell cell = (EntryElementCell)tv.DequeueReusableCell("DateTimeElement");
			if (cell == null){
				cell = new EntryElementCell("DateTimeElement");
			} 

			cell.Update(this, tv);
			var picker = CreatePicker();
			picker.ValueChanged += (sender, e) => { 
				this.DateValue = picker.Date;
				cell.DetailTextLabel.Text = FormatDate(picker.Date); 
				this.Value = FormatDate(picker.Date);
				cell.SetNeedsLayout();
			};
			cell.TextField.EditingDidBegin += (sender, e) => {
				this.DateValue = picker.Date;
				cell.DetailTextLabel.Text = FormatDate(picker.Date); 
				this.Value = FormatDate(picker.Date);
				cell.SetNeedsLayout();
			};

			cell.TextField.InputView = picker;
			cell.TextField.Alpha = 0;
			cell.TextLabel.TextColor = Appearance.LabelTextColor;
			
			cell.TextLabel.HighlightedTextColor = Appearance.LabelHighlightedTextColor;
			cell.TextLabel.Font = Appearance.LabelFont;
			
			cell.DetailTextLabel.Text = FormatDate(this.DateValue); 
			cell.DetailTextLabel.TextColor = Appearance.DetailLabelTextColor;
			cell.DetailTextLabel.Font = Appearance.DetailLabelFont;
			cell.DetailTextLabel.HighlightedTextColor = Appearance.DetailLabelHighlightedTextColor;


			cell.BackgroundColor = Appearance.BackgroundColorEditable;

			var toolbar =  new UIToolbar();
			toolbar.Items = new UIBarButtonItem[] {
				new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
				new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (e, a)=>{
					cell.TextField.ResignFirstResponder();
				})
			};
			toolbar.SizeToFit();
			cell.TextField.InputAccessoryView = toolbar;				
			return cell;
		}
开发者ID:escoz,项目名称:MonoMobile.Forms,代码行数:49,代码来源:DateTimeElement.cs

示例8: 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

示例9: ViewWillAppear

	    public override void ViewWillAppear(bool animated)
	    {
	        base.ViewWillAppear(animated);

            var rawStatuses = Enum.GetValues(typeof(CommitmentStatus));
            var statuses = new CommitmentStatus[rawStatuses.Length];
            var i = 0;
            foreach (CommitmentStatus status in rawStatuses)
            {
                statuses[i] = status;
                i++;
            }
            _pickerModel = new PickerModel(statuses);
            _statusSelectedEventHandler = (sender, args) =>
            {
                _selectedStatus = args.SelectedValue;
            };
            _pickerModel.PickerChanged += _statusSelectedEventHandler;

            _statusPicker = new UIPickerView
            {
                ShowSelectionIndicator = true,
                Model = _pickerModel
            };

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

            _barButtonClickEventHandler = (s, e) =>
            {
                DisasterStatusText.Text = Enum.GetName(typeof(CommitmentStatus), _selectedStatus);
                DisasterStatusText.ResignFirstResponder();
            };
            // Create a 'done' button for the toolbar and add it to the toolbar
            _doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, _barButtonClickEventHandler);
            toolbar.SetItems(new[] { _doneButton }, true);

            // Tell the textbox to use the picker for input
            DisasterStatusText.InputView = _statusPicker;

            // Display the toolbar over the pickers
            DisasterStatusText.InputAccessoryView = toolbar;
	    }
开发者ID:mjmilan,项目名称:crisischeckin,代码行数:48,代码来源:CommitmentViewController.cs

示例10: pickerViewModel

        public void pickerViewModel(UITextField textFieldItem, List<string> segmentosStrings, UIButton button)
        {
            PickerModel picker_model_Segmentos = new PickerModel (segmentosStrings);
            UIPickerView picker_Segmentos = new UIPickerView ();
            picker_Segmentos.Model = picker_model_Segmentos;
            picker_Segmentos.ShowSelectionIndicator = true;

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

            var tapRecognizer = new UITapGestureRecognizer ();

            tapRecognizer.AddTarget(() => {
                Console.WriteLine("CLICK");
            });

            tapRecognizer.NumberOfTapsRequired = 2;
            tapRecognizer.NumberOfTouchesRequired = 1;

            picker_Segmentos.AddGestureRecognizer(tapRecognizer);

            UIBarButtonItem doneButton = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Bordered,(s, e) => {
                //				Console.WriteLine((int)picker_Segmentos.SelectedRowInComponent);
                Console.WriteLine(picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ());
                textFieldItem.Text = picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ();
                if(button.Tag == 2 || button.Tag == 3){
                    Console.WriteLine("longCode ButtonClicked");
                }

                textFieldItem.ResignFirstResponder ();
            });

            UIBarButtonItem cancelButton = new UIBarButtonItem ("cancel", UIBarButtonItemStyle.Bordered, (s, e) => {
                textFieldItem.ResignFirstResponder ();
            });
            toolbar.SetItems (new UIBarButtonItem[]{ doneButton, cancelButton }, true);
            toolbar.TintColor = UIColor.White;
            textFieldItem.InputView = picker_Segmentos;
            this.View.BackgroundColor = UIColor.Clear;
            textFieldItem.InputAccessoryView = toolbar;
            textFieldItem.AddGestureRecognizer (tapRecognizer);
        }
开发者ID:kumaralg2,项目名称:Jan28-TS,代码行数:44,代码来源:TSSetupCodeVC.cs

示例11: ViewDidLoad

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

		Title = "Toolbar";

		View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
		toolbar = new UIToolbar() {
			BarStyle = UIBarStyle.Default
		};
		toolbar.SizeToFit ();
		float toolbarHeight = toolbar.Frame.Height;
		var mainViewBounds = View.Bounds;
		toolbar.Frame = new RectangleF (mainViewBounds.X, (float)(mainViewBounds.Y + mainViewBounds.Height - toolbarHeight * 2 + 2),
						mainViewBounds.Width, toolbarHeight);
		View.AddSubview (toolbar);
		currentSystemItem = UIBarButtonSystemItem.Done;
		CreateToolbarItems ();

		systemButtonPicker.Model = new ItemPickerModel (this);
	}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:21,代码来源:toolbar.cs

示例12: 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

示例13: ActionSheetPicker

        /// <summary>
        /// 
        /// </summary>
        public ActionSheetPicker(UIView owner)
        {
            // save our uiview owner
            this._owner = owner;

            // configure the title label
            titleLabel.BackgroundColor = UIColor.Clear;
            titleLabel.TextColor = UIColor.LightTextColor;
            titleLabel.Font = UIFont.BoldSystemFontOfSize (18);

            // create + configure the action sheet
            _actionSheet = new UIActionSheet () { Style = UIActionSheetStyle.BlackTranslucent };
            _actionSheet.Clicked += (s, e) => { Console.WriteLine ("Clicked on item {0}", e.ButtonIndex); };

            // add our controls to the action sheet
            _actionSheet.AddSubview (picker);
            _actionSheet.AddSubview (titleLabel);
            //actionSheet.AddSubview (doneButton);

            // Add the toolbar
            _toolbar = new UIToolbar(new RectangleF(0, 0, _actionSheet.Frame.Width, 10));
            _toolbar.BarStyle = UIBarStyle.Black;
            _toolbar.Translucent = true;

            // Add the done button
            _doneButton = new UIBarButtonItem("Aceptar",UIBarButtonItemStyle.Done, null);
            _doneButton.Clicked += (object sender, EventArgs e) => {
                _actionSheet.DismissWithClickedButtonIndex (0, true);
            };

            _toolbar.Items = new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null),
                _doneButton
            };

            _toolbar.SizeToFit();

            _actionSheet.Add (_toolbar);
        }
开发者ID:saedaes,项目名称:gestion2013,代码行数:42,代码来源:ActionSheetPicker.cs

示例14: ActionSheetDatePickerCustom

	public ActionSheetDatePickerCustom (UIView owner)
	{
		picker = new UIDatePicker (CGRect.Empty);

		// save our uiview owner
		this._owner = owner;
              
		// create + configure the action sheet
		_actionSheet = new UIActionSheet () { Style = UIActionSheetStyle.BlackTranslucent };
		_actionSheet.Clicked += (s, e) => {
			Console.WriteLine ("Clicked on item {0}", e.ButtonIndex);
		};
                
		// configure the title label
		titleLabel = new UILabel (new CGRect (0, 0, _actionSheet.Frame.Width, 10));
		titleLabel.BackgroundColor = UIColor.Clear;
		titleLabel.TextColor = UIColor.Black;
		titleLabel.Font = UIFont.BoldSystemFontOfSize (18);

		// Add the toolbar
		_toolbar = new UIToolbar (new CGRect (0, 0, _actionSheet.Frame.Width, 10));
		_toolbar.BarStyle = UIBarStyle.Default;
		_toolbar.Translucent = true;

		// Add the done button
		_doneButton = new UIBarButtonItem ("Gereed", UIBarButtonItemStyle.Done, null);
                
		_toolbar.Items = new UIBarButtonItem[] {
			new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null, null),
			_doneButton
		};
                
		_toolbar.SizeToFit ();
               
		_actionSheet.AddSubview (picker);
		_actionSheet.Add (_toolbar);
		_actionSheet.AddSubview (titleLabel);
	}
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:38,代码来源:ActionSheetDatePickerCustom.cs

示例15: 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:kumpera,项目名称:NLuaBox,代码行数:23,代码来源:AppDelegate.cs


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