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


C# UITextField.SizeToFit方法代码示例

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


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

示例1: EditExpenseView

		public EditExpenseView ()
		{
			this.BackgroundColor = UIColor.DarkGray;

			TripHeaderView = new TripInfoHeaderView ();

			addExpenseLabel = new UILabel () {
				Font = UIFont.FromName("AvenirNext-Bold", 17f),
				TextAlignment = UITextAlignment.Left,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White,
				Text = "add new expense"

			};

			expenseName = new UITextField () { 
				Placeholder = "expense name?",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White
			};

			date = new ActionSheetDatePicker (this);
			date.Title = "Choose Date:";
			date.DatePicker.Mode = UIDatePickerMode.Date;
			date.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				buttonDate.SetTitle(selectedDate.ToString("d"), UIControlState.Normal); 
			};

			amount = new UITextField () { 
				Placeholder = "$ amount?",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				KeyboardType = UIKeyboardType.NumberPad
			};




			buttonDate = UIButton.FromType (UIButtonType.Custom);
			buttonDate.SetTitle ("spent on Wednessday, Jul 17, 2013", UIControlState.Normal);
			buttonDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			buttonDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			buttonDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);

			buttonDate.TouchUpInside += (sender, e) => {
				date.Show(); 
			};

			TripHeaderView.SizeToFit ();
			addExpenseLabel.SizeToFit();
			buttonDate.SizeToFit();
			expenseName.SizeToFit();
			amount.SizeToFit();

			AddSubviews (TripHeaderView, addExpenseLabel, expenseName, amount, buttonDate);
		}
开发者ID:McKabue,项目名称:TripXpense,代码行数:61,代码来源:EditExpenseScreenController.cs

示例2: EditTripScreenView

		public EditTripScreenView (RectangleF frame, Trip trip)
		{
			//this.Frame = frame;

			_scrollView = new UIScrollView (frame);
			this.BackgroundColor = UIColor.White;

			_tripNameTextField = new UITextField () { 
				Placeholder = "Trip Name",
				BorderStyle = UITextBorderStyle.RoundedRect,
			};

			_tripNameTextField = new UITextField () { 
				Placeholder = "trip name",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White
			};

			_btnStartDate = UIButton.FromType (UIButtonType.Custom);
			_btnStartDate.SetTitle ("from Wednessday, Jul 17, 2013", UIControlState.Normal);
			_btnStartDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			_btnStartDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			_btnStartDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);



			actionSheetDatePickerStartDate = new ActionSheetDatePicker (this);
			actionSheetDatePickerStartDate.Title = "Choose Date:";
			actionSheetDatePickerStartDate.DatePicker.Mode = UIDatePickerMode.Date;
			actionSheetDatePickerStartDate.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				_btnStartDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal); 
			};

			_btnStartDate.TouchUpInside += (sender, e) => {
				actionSheetDatePickerStartDate.Show(); 
			};

			_btnEndDate = UIButton.FromType (UIButtonType.Custom);
			_btnEndDate.SetTitle ("to Wednessday, Jul 17, 2013", UIControlState.Normal);
			_btnEndDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			_btnEndDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			_btnEndDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);

			_btnEndDate.TouchUpInside += (sender, e) => {
				actionSheetDatePickerEndDate.Show();
			};
			actionSheetDatePickerEndDate = new ActionSheetDatePicker (this);
			actionSheetDatePickerEndDate.Title = "Choose Date:";
			actionSheetDatePickerEndDate.DatePicker.Mode = UIDatePickerMode.Date;
			actionSheetDatePickerEndDate.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				_btnEndDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal); 
			};


			_tripDescTextField = new UITextView () { 
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				Text = "Desc"
			};


			_tripBudgetTextField = new UITextField () { 
				Placeholder = "budget",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				KeyboardType = UIKeyboardType.NumberPad
			};

			ButtonExpenses = UIButton.FromType (UIButtonType.RoundedRect);
			ButtonExpenses.SetTitle ("expenses", UIControlState.Normal);


			ButtonDeleteTrip = UIButton.FromType (UIButtonType.RoundedRect);
			ButtonDeleteTrip.SetTitle ("delete trip", UIControlState.Normal);

			_tripNameTextField.SizeToFit ();
			_btnStartDate.SizeToFit ();
			_btnEndDate.SizeToFit ();
			_tripDescTextField.SizeToFit ();
			_tripBudgetTextField.SizeToFit ();
			ButtonExpenses.SizeToFit ();

			ButtonDeleteTrip.SizeToFit();

			_tripNameTextField.ShouldReturn += (t) => {
				t.ResignFirstResponder();
				return true;
			};


			// set content size to default for now
			//TODO: implement observer and set accordingly
			_scrollView.ContentSize = new SizeF (frame.Width, frame.Height);
//.........这里部分代码省略.........
开发者ID:McKabue,项目名称:TripXpense,代码行数:101,代码来源:EditTripScreenController.cs


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