本文整理汇总了C#中UILabel.SizeToFit方法的典型用法代码示例。如果您正苦于以下问题:C# UILabel.SizeToFit方法的具体用法?C# UILabel.SizeToFit怎么用?C# UILabel.SizeToFit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UILabel
的用法示例。
在下文中一共展示了UILabel.SizeToFit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCell
public override UITableViewCell GetCell(UITableView tv)
{
RectangleF frame;
if (datePicker == null)
{
label = new UILabel
{
Text = Caption
};
label.SizeToFit();
frame = label.Frame;
frame.X = 15;
frame.Y = 5;
label.Frame = frame;
datePicker = CreatePicker();
}
if(datePicker.Date != DateValue)
datePicker.Date = DateValue;
frame = datePicker.Frame;
frame.Y = frame.X = 0;
datePicker.Frame = frame;
var cell = tv.DequeueReusableCell("datePicker") ?? new UITableViewCell(UITableViewCellStyle.Default, "datePicker") { Accessory = UITableViewCellAccessory.None };
cell.ContentView.Add(label);
if(cell.ContentView != datePicker.Superview)
cell.ContentView.Add(datePicker);
return cell;
}
示例2: ProductDescriptionView
public ProductDescriptionView()
{
//this.TranslatesAutoresizingMaskIntoConstraints = false;
Name = new UILabel
{
Text = "Name",
BackgroundColor = UIColor.Clear,
TextColor = UIColor.DarkGray,
Font = UIFont.SystemFontOfSize(25f),
TranslatesAutoresizingMaskIntoConstraints = false,
};
Name.SizeToFit();
this.AddSubview(Name);
DescriptionLabel = new UILabel
{
BackgroundColor = UIColor.Clear,
TextColor = UIColor.DarkGray,
TranslatesAutoresizingMaskIntoConstraints = false,
Font = UIFont.SystemFontOfSize(12),
LineBreakMode = UILineBreakMode.WordWrap,
Lines = 0
};
AddSubview(DescriptionLabel);
Price = new UILabel
{
BackgroundColor = UIColor.Clear,
Text = "Price",
TextColor = Color.Blue,
TranslatesAutoresizingMaskIntoConstraints = false,
};
Price.SizeToFit();
AddSubview(Price);
}
示例3: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
recipes = DataLoader.GetRecipes ();
var toolbarBg = FoodyTheme.SharedTheme.ToolbarBackgroundForSplitView (true);
ToolbarBottom.SetBackgroundImage (toolbarBg, UIToolbarPosition.Bottom, UIBarMetrics.Default);
var navbarBg = FoodyTheme.SharedTheme.NavigationBackgroundForSplitView (true);
NavigationController.NavigationBar.SetBackgroundImage (navbarBg, UIBarMetrics.Default);
DishTableView.WeakDelegate = this;
DishTableView.WeakDataSource = this;
DishTableView.BackgroundColor = UIColor.Clear;
DishTableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
var label = new UILabel ();
label.BackgroundColor = UIColor.Clear;
label.Font = UIFont.SystemFontOfSize (20);
label.ShadowColor = UIColor.Black;
label.TextAlignment = UITextAlignment.Center;
label.TextColor = UIColor.White;
NavigationItem.TitleView = label;
label.Text = "Dishes";
label.SizeToFit ();
FoodyTheme.Apply (View);
}
示例4: RenderStream
public void RenderStream (Stream stream)
{
var reader = new StreamReader (stream);
InvokeOnMainThread (delegate {
button1.Enabled = true;
var view = new UIViewController ();
var handler = new UILabel (new CGRect (20, 20, 300, 40)) {
Text = "HttpClient is using " + HandlerType?.Name,
Lines = 0
};
handler.SizeToFit ();
var label = new UILabel (new CGRect (20, 40, 300, 80)) {
Text = "The HTML returned by the server:"
};
var tv = new UITextView (new CGRect (20, 100, 300, 400)) {
Text = reader.ReadToEnd ()
};
if (HandlerType != null)
view.Add (handler);
view.Add (label);
view.Add (tv);
if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
view.EdgesForExtendedLayout = UIRectEdge.None;
}
navigationController.PushViewController (view, true);
});
}
示例5: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
UIView header = new UIView(new System.Drawing.RectangleF(0, 0, 0, 184f));
UIImageView imageView = new UIImageView(new System.Drawing.RectangleF(0, 40f, 100f, 100f));
imageView.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
imageView.Image = UIImage.FromBundle("avatar.jpg");
imageView.Layer.MasksToBounds = true;
imageView.Layer.CornerRadius = 50f;
imageView.Layer.BorderColor = UIColor.White.CGColor;
imageView.Layer.BorderWidth = 3f;
imageView.Layer.RasterizationScale = UIScreen.MainScreen.Scale;
imageView.Layer.ShouldRasterize = true;
imageView.ClipsToBounds = true;
UILabel label = new UILabel(new System.Drawing.RectangleF(0, 150f, 0, 24f)){
Text = "Roman Efimov",
Font = UIFont.SystemFontOfSize(21f),
BackgroundColor = UIColor.Clear,
TextColor = UIColor.FromRGBA(62/255f, 68/255f, 75/255f, 1f)
};
label.SizeToFit();
label.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
header.AddSubview(imageView);
header.AddSubview(label);
TableView.SeparatorColor = UIColor.FromRGBA(150/255f, 161/255f, 177/255f, 1f);
TableView.Source = new DEMOTableSource(this);
TableView.Opaque = false;
TableView.BackgroundColor = UIColor.Clear;
TableView.TableHeaderView = header;
}
示例6: PrimaryCell
public PrimaryCell( CGSize parentSize, UITableViewCellStyle style, string cellIdentifier ) : base( style, cellIdentifier )
{
BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
SelectionStyle = UITableViewCellSelectionStyle.None;
Image = new UIImageView( );
Image.BackgroundColor = UIColor.Yellow;
Image.ContentMode = UIViewContentMode.ScaleAspectFill;
Image.Layer.AnchorPoint = CGPoint.Empty;
AddSubview( Image );
// Banner Image
Image.Image = new UIImage( NSBundle.MainBundle.BundlePath + "/" + PrivateConnectConfig.MainPageHeaderImage );
Image.SizeToFit( );
// resize the image to fit the width of the device
nfloat imageAspect = Image.Bounds.Height / Image.Bounds.Width;
Image.Frame = new CGRect( 0, 0, parentSize.Width, parentSize.Width * imageAspect );
Title = new UILabel( );
Title.Text = ConnectStrings.Main_Connect_Header;
Title.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize );
Title.Layer.AnchorPoint = CGPoint.Empty;
Title.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
Title.LineBreakMode = UILineBreakMode.TailTruncation;
Title.TextAlignment = UITextAlignment.Center;
Title.Frame = new CGRect( 5, Image.Frame.Bottom, parentSize.Width - 10, 0 );
Title.SizeToFit( );
AddSubview( Title );
}
示例7: BlurredAlertView
private BlurredAlertView(string text)
{
_label = new UILabel();
_label.Lines = 0;
_label.Text = text;
_label.Font = UIFont.PreferredHeadline;
_label.TextAlignment = UITextAlignment.Center;
_label.TextColor = UIColor.White;
_button = new UIButton(UIButtonType.Custom);
var buttonLabel = new UILabel();
buttonLabel.Text = "Ok";
buttonLabel.Font = UIFont.PreferredBody.MakeBold();
buttonLabel.TextColor = UIColor.White;
buttonLabel.SizeToFit();
buttonLabel.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
_button.Add(buttonLabel);
_button.Layer.BorderColor = UIColor.White.CGColor;
_button.Layer.BorderWidth = 1f;
_button.Layer.CornerRadius = 6f;
_button.Layer.MasksToBounds = true;
}
示例8: BasketViewController
public BasketViewController (Order order)
{
this.Title = "Your Basket";
//This hides the back button text when you leave this View Controller
this.NavigationItem.BackBarButtonItem = new UIBarButtonItem ("", UIBarButtonItemStyle.Plain, handler: null);
TableView.Source = new TableViewSource (this.order = order) {
RowDeleted = CheckEmpty,
};
TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
TableView.RowHeight = 75;
TableView.TableFooterView = new UIView (new RectangleF (0, 0, 0, BottomButtonView.Height));
this.View.AddSubview (BottomView = new BottomButtonView () {
ButtonText = "Checkout",
ButtonTapped = () => {
if (Checkout != null)
Checkout (this, EventArgs.Empty);
}
});
CheckEmpty (false);
totalAmount = new UILabel () {
Text = "$1,000",
TextColor = UIColor.White,
TextAlignment = UITextAlignment.Center,
Font = UIFont.BoldSystemFontOfSize (17),
};
totalAmount.SizeToFit ();
this.NavigationItem.RightBarButtonItem = new UIBarButtonItem (totalAmount);
UpdateTotals ();
}
示例9: ForumTopicPostsTableCell
public ForumTopicPostsTableCell(NSString cellId)
: base(UITableViewCellStyle.Default, cellId)
{
try
{
SelectionStyle = UITableViewCellSelectionStyle.Gray;
headingLabel = new UILabel()
{
TextAlignment = UITextAlignment.Left,
BackgroundColor = UIColor.Gray,
TextColor = UIColor.White,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap
};
headingLabel.Font = UIFont.FromName(headingLabel.Font.Name, headingLabel.Font.PointSize - 2);
textLabel = new UILabel();
textLabel.Lines = 0;
textLabel.LineBreakMode = UILineBreakMode.WordWrap;
textLabel.SizeToFit();
textLabel.Font = UIFont.FromName(textLabel.Font.Name, textLabel.Font.PointSize);
ContentView.Add(headingLabel);
ContentView.Add(textLabel);
//ContentView.SizeToFit();
}
catch (Exception exception)
{
ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
}
}
示例10: LoadAllowedTextsLabel
void LoadAllowedTextsLabel()
{
UILabel label = new UILabel ();
label.Frame = frameRect;
label.TextColor = UIColor.FromRGB (38/255.0f, 38/255.0f, 38/255.0f);
label.Text = "Allowed Characters";
label.Font = UIFont.BoldSystemFontOfSize(12);
label.SizeToFit();
label.Frame = new CGRect(frameRect.Location.X, 10, frameRect.Size.Width, label.Frame.Size.Height);
this.AddSubview (label);
frameRect.Location = new CGPoint(frameRect.Location.X, (10 + label.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, (frameRect.Size.Height - label.Frame.Size.Height + frameMargin));
UILabel allowedTextsLabel = new UILabel ();
allowedTextsLabel.Frame = frameRect;
allowedTextsLabel.TextColor = UIColor.FromRGB (63/255.0f, 63/255.0f, 63/255.0f);
allowedTextsLabel.Text = "ASCII values from 0 to 95\nNUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SPACE ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ]^ _";
allowedTextsLabel.Font = UIFont.SystemFontOfSize (10.0f);
allowedTextsLabel.Lines = 0;
allowedTextsLabel.SizeToFit ();
allowedTextsLabel.Frame = new CGRect(frameRect.Location.X, frameRect.Location.Y, frameRect.Size.Width , allowedTextsLabel.Frame.Size.Height);
this.AddSubview(allowedTextsLabel);
frameRect.Location = new CGPoint(frameRect.Location.X, (frameRect.Location.Y + allowedTextsLabel.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, frameRect.Size.Height - allowedTextsLabel.Frame.Size.Height);
}
示例11: ViewWillAppear
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear (animated);
// Perform any additional setup after loading the view, typically from a nib.
UILabel lab = new UILabel ()
{
Text = "Hallo World!",
Font = UIFont.SystemFontOfSize(40f),
AutoresizingMask = UIViewAutoresizing.All
};
lab.SizeToFit ();
lab.Center = this.View.Center;
this.View.BackgroundColor = UIColor.ScrollViewTexturedBackgroundColor;
var pageView = new UIView(new RectangleF(0, 0, 680, 900))
{
BackgroundColor = UIColor.White,
AutoresizingMask = UIViewAutoresizing.FlexibleDimensions,
Center = this.View.Center
};
this.View.AddSubview(pageView);
pageView.AddSubview (lab);
}
示例12: LoadAllowedTextsLabel
void LoadAllowedTextsLabel()
{
UILabel label = new UILabel ();
label.Frame = frameRect;
label.TextColor = UIColor.FromRGB (38/255.0f, 38/255.0f, 38/255.0f);
label.Text = "Allowed Characters";
label.Font = UIFont.BoldSystemFontOfSize(12);
label.SizeToFit();
label.Frame = new CGRect(frameRect.Location.X, 10, frameRect.Size.Width, label.Frame.Size.Height);
this.AddSubview (label);
frameRect.Location = new CGPoint(frameRect.Location.X, (10 + label.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, (frameRect.Size.Height - label.Frame.Size.Height + frameMargin));
UILabel allowedTextsLabel = new UILabel ();
allowedTextsLabel.Frame = frameRect;
allowedTextsLabel.TextColor = UIColor.FromRGB (63/255.0f, 63/255.0f, 63/255.0f);
allowedTextsLabel.Text = "All 128 ASCII Characters";
allowedTextsLabel.Font = UIFont.SystemFontOfSize (10.0f);
allowedTextsLabel.Lines = 0;
allowedTextsLabel.SizeToFit ();
this.AddSubview(allowedTextsLabel);
frameRect.Location = new CGPoint(frameRect.Location.X, (frameRect.Location.Y + allowedTextsLabel.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, frameRect.Size.Height - allowedTextsLabel.Frame.Size.Height);
}
示例13: LoadAllowedTextsLabel
void LoadAllowedTextsLabel()
{
UILabel label = new UILabel ();
label.Frame = frameRect;
label.TextColor = UIColor.FromRGB (38/255.0f, 38/255.0f, 38/255.0f);
label.Text = "Allowed Characters";
label.Font = UIFont.BoldSystemFontOfSize(12);
label.SizeToFit();
label.Frame = new CGRect(frameRect.Location.X, 10, frameRect.Size.Width, label.Frame.Size.Height);
this.AddSubview (label);
frameRect.Location = new CGPoint(frameRect.Location.X, (10 + label.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, (frameRect.Size.Height - label.Frame.Size.Height + frameMargin));
UILabel allowedTextsLabel = new UILabel ();
allowedTextsLabel.Frame = frameRect;
allowedTextsLabel.TextColor = UIColor.FromRGB (63/255.0f, 63/255.0f, 63/255.0f);
allowedTextsLabel.Text = "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z dash(-) dot(.) $ / + % SPACE";
allowedTextsLabel.Font = UIFont.SystemFontOfSize (10.0f);
allowedTextsLabel.Lines = 0;
allowedTextsLabel.SizeToFit ();
allowedTextsLabel.Frame = new CGRect(frameRect.Location.X, frameRect.Location.Y, frameRect.Size.Width , allowedTextsLabel.Frame.Size.Height);
this.AddSubview(allowedTextsLabel);
frameRect.Location = new CGPoint(frameRect.Location.X, (frameRect.Location.Y + allowedTextsLabel.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, frameRect.Size.Height - allowedTextsLabel.Frame.Size.Height);
}
示例14: LoadAllowedTextsLabel
void LoadAllowedTextsLabel()
{
UILabel label = new UILabel ();
label.Frame = frameRect;
label.Text = "Allowed Characters";
label.TextColor = UIColor.FromRGB (38/255.0f, 38/255.0f, 38/255.0f);
label.Font = UIFont.BoldSystemFontOfSize(12);
label.SizeToFit();
label.Frame = new CGRect(frameRect.Location.X, 10, frameRect.Size.Width, label.Frame.Size.Height);
this.AddSubview (label);
frameRect.Location = new CGPoint(frameRect.Location.X, (10+ label.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, (frameRect.Size.Height - label.Frame.Size.Height + frameMargin));
UILabel allowedTextsLabel = new UILabel ();
allowedTextsLabel.Frame = frameRect;
allowedTextsLabel.TextColor = UIColor.FromRGB (63/255.0f, 63/255.0f, 63/255.0f);
allowedTextsLabel.Text = "ASCII values from 32 to 127\nSPACE ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ]^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ DEL";
allowedTextsLabel.Font = UIFont.SystemFontOfSize (10.0f);
allowedTextsLabel.Lines = 0;
allowedTextsLabel.SizeToFit ();
allowedTextsLabel.Frame = new CGRect(frameRect.Location.X, frameRect.Location.Y, frameRect.Size.Width , allowedTextsLabel.Frame.Size.Height);
this.AddSubview(allowedTextsLabel);
frameRect.Location = new CGPoint(frameRect.Location.X, (frameRect.Location.Y + allowedTextsLabel.Frame.Size.Height + frameMargin));
frameRect.Size = new CGSize(frameRect.Size.Width, frameRect.Size.Height - allowedTextsLabel.Frame.Size.Height);
}
示例15: FinishedLaunching
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// check is it 64bit or 32bit
Console.WriteLine (IntPtr.Size);
// Main app do nothing
// Go to Photo > Edit then choose PhotoFilter to start app extension
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.BackgroundColor = UIColor.White;
note = new UILabel ();
note.Text = "Note that the app in this sample only serves as a host for the extension. To use the sample extension, edit a photo or video using the Photos app, and tap the extension icon";
note.Lines = 0;
note.LineBreakMode = UILineBreakMode.WordWrap;
var frame = note.Frame;
note.Frame = new CGRect (0, 0, UIScreen.MainScreen.Bounds.Width * 0.75f, 0);
note.SizeToFit ();
window.AddSubview (note);
note.Center = window.Center;
window.MakeKeyAndVisible ();
return true;
}