本文整理汇总了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;
}
示例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);
//.........这里部分代码省略.........