本文整理汇总了C#中UIView.SizeToFit方法的典型用法代码示例。如果您正苦于以下问题:C# UIView.SizeToFit方法的具体用法?C# UIView.SizeToFit怎么用?C# UIView.SizeToFit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIView
的用法示例。
在下文中一共展示了UIView.SizeToFit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
_view = new UIView();
_view.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
UILabel label = new UILabel();
label.Text = _stopInfo.StopName;
label.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
label.SizeToFit();
label.Frame = new RectangleF(10,0, 300, 40);
_view.Add(label);
UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
button.SetTitle("Legg til i favoritter", UIControlState.Normal);;
button.Frame = new RectangleF(10, 120, 150, 50);
_view.Add(button);
_view.SizeToFit();
button.TouchUpInside += delegate {
_busStopRepository.AddFavorite(_stopInfo);
};
webView = new UIWebView { ScalesPageToFit = false };
webView.LoadHtmlString (FormatText (), new NSUrl ());
// Set the web view to fit the width of the app.
webView.SizeToFit ();
// Reposition and resize the receiver
_view.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);
// Add the table view as a subview
this.View.AddSubview (_view);
}
示例2: TripInfoView
public TripInfoView ()
{
TripHeaderView = new TripInfoHeaderView ();
ExpensesViewList = new ExpensesView ();
this.BackgroundColor = UIColor.DarkGray;
AddNewExpenseButton = UIButton.FromType (UIButtonType.ContactAdd);
expensesLabel = new UILabel () {
Font = UIFont.FromName("AvenirNext-Bold", 17f),
TextAlignment = UITextAlignment.Left,
BackgroundColor = UIColor.Clear,
TextColor = UIColor.White,
Text = "expenses"
};
total = new UILabel () {
Font = UIFont.FromName("AvenirNext-Bold", 14f),
TextAlignment = UITextAlignment.Left,
BackgroundColor = UIColor.Clear,
TextColor = UIColor.White,
Text = "total: $260"
};
TripHeaderView.SizeToFit();
ExpensesViewList.SizeToFit();
expensesLabel.SizeToFit ();
total.SizeToFit();
AddSubviews (TripHeaderView, expensesLabel, AddNewExpenseButton, ExpensesViewList, total);
}
示例3: 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);
}
示例4: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// For accelerometer readings
motionManager = new CMMotionManager();
motionManager.AccelerometerUpdateInterval = 0.01; // 100Hz
//To handle long presses and bring up path start/end menu
var longPressManager = new UILongPressGestureRecognizer();
//Graph loading code
//Graph loading code
var assembly = Assembly.GetExecutingAssembly();
var asset = assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsfloorWideDoors.xml");
pf = new Pathfinding.Pathfinding(new Dictionary<int, Stream>()
{
{0,assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsfloorWideDoors.xml")},
{1,assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsFloor1.xml")}
},assembly.GetManifestResourceStream("Navigator.iOS.Resources.Rooms.xml") );
pf.CurrentFloor = 0;
while (true)
{
if (pf.Ready)
break;
Thread.Sleep(500);
}
//set up the search bar and prediction box
var searchController = new CustomSearchController(this, SearchBar, SearchPredictionTable, pf.Rooms);
floorPlanGraph = Graph.Load(asset);
wallCollImg = UIImage.FromBundle("Images/dcsfloorWideDoors.png");
col = new Collision(floorPlanGraph, new StepDetector());
((Collision)col).WallCol = new WallCollision ((x,y) => GetPixelColor(new PointF(x, y), wallCollImg));
wallColTest = new WallCollision ((x,y) => GetPixelColor(new PointF(x, y), wallCollImg));
pathView = new PathView (wallColTest);
col.SetLocation(707.0f, 677.0f);
col.PassHeading(90);
col.PositionChanged += HandleStepsTaken;
//Container for floorplan and any overlaid images
var container = new UIView();
//Will contain floorplan images
floorplanImageView = new UIImageView();
//Load floorplan images
floorplanImageNoGrid = UIImage.FromBundle("Images/FinalDcsFloor1.png");
floorplanImageWithGrid = UIImage.FromBundle("Images/dcsFloorWideDoorsGrid.png");
//Initiate the location arrow
locationArrow = new LocationArrowImageView();
locationArrow.ScaleFactor = floorplanView.ZoomScale;
pathView.ScaleFactor = floorplanView.ZoomScale;
setStartPoint(690.0f, 840.0f);
//Set sizes for floorplan view and path view
floorplanView.ContentSize = floorplanImageNoGrid.Size;
pathView.Frame = new CGRect(new CGPoint(0, 0), floorplanImageNoGrid.Size);
//Add subviews to the container (including pathview and floorplanview)
container.AddSubview(floorplanImageView);
container.AddSubview(locationArrow);
floorplanImageView.AddSubview(pathView);
changeFloorPlanImage(floorplanImageView, floorplanImageNoGrid);
container.SizeToFit();
//Adjust scrolling and zooming properties for the floorplanView
floorplanView.MaximumZoomScale = 1f;
floorplanView.MinimumZoomScale = .25f;
floorplanView.AddSubview(container);
floorplanView.ViewForZoomingInScrollView += (UIScrollView sv) => { return floorplanImageView; };
//Variables needed to convert device acceleration to world z direction acceleration
double accelX = 0, accelY = 0, accelZ = 0;
//Scale location arrow and paths when zooming the floorplan
floorplanView.DidZoom += (sender, e) =>
{
locationArrow.ScaleFactor = floorplanView.ZoomScale;
pathView.ScaleFactor = floorplanView.ZoomScale;
};
//Pass acceleremoter values to the collision class
motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue,
(data, error) =>
{
accelX = data.Acceleration.X*9.8;
accelY = data.Acceleration.Y*9.8;
accelZ = Math.Sqrt(Math.Pow(accelX, 2) + Math.Pow(accelY, 2) + Math.Pow(data.Acceleration.Z*9.8, 2));
//.........这里部分代码省略.........
示例5: layoutElementBelow
private void layoutElementBelow(UIView topElement, UIView bottomElement, int padding)
{
bottomElement.Frame = new RectangleF(_margin, topElement.Frame.Y + topElement.Frame.Height + padding,
ElementWidth, 0);
bottomElement.SizeToFit();
}