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


C# UITextView.SizeToFit方法代码示例

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


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

示例1: GetHeightForRow

        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            var height = base.GetHeightForRow(tableView, indexPath);
            var font = UIFont.SystemFontOfSize(15.0f);

            var textView = new UITextView (new CGRect (0, 0, tableView.Frame.Width, Int32.MaxValue)) {
                Text = reviews[indexPath.Section].Text,
                Font = font
            };

            textView.SizeToFit();

            if (font.LineHeight != textView.Frame.Height)
                height += textView.Frame.Height;

            return height;
        }
开发者ID:RobGibbens,项目名称:Coffee-Filter,代码行数:17,代码来源:ReviewsViewController.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


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