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


C# UIButton.SizeThatFits方法代码示例

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


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

示例1: loadIPadLayout

 void loadIPadLayout()
 {
     CGSize desiredSize = CGSize.Empty;
     this.offset = 0;
     if (sections.Count == 0 && options.Count == 1)
     {
         UIButton button = new UIButton (UIButtonType.RoundedRect);
         button.SetTitle (options [0].OptionText, UIControlState.Normal);
         button.AddTarget (optionTouched, UIControlEvent.TouchUpInside);
         desiredSize = button.SizeThatFits (this.View.Bounds.Size);
         button.Frame = new CGRect (30, 10 + this.headerHeight, desiredSize.Width, desiredSize.Height);
         this.View.AddSubview (button);
         this.offset = (float)(10 + desiredSize.Height + 10);
     }
     else if (options.Count >= 3 || sections.Count > 0)
     {
         settingsButton = new UIBarButtonItem (new UIImage ("menu.png"), UIBarButtonItemStyle.Plain, settingsTouched);
         this.NavigationItem.RightBarButtonItem = settingsButton;
     }
     else
     {
         UISegmentedControl segmented = new UISegmentedControl ();
         for (int i = 0; i < options.Count; i++) {
             segmented.InsertSegment (options [i].OptionText, i + 1, false);
         }
         desiredSize = segmented.SizeThatFits (this.View.Bounds.Size);
         segmented.Frame = new CGRect (10, 10 + this.headerHeight, desiredSize.Width, desiredSize.Height);
         segmented.AddTarget (optionTouched, UIControlEvent.ValueChanged);
         this.View.AddSubview (segmented);
         segmented.SelectedSegment = this.SelectedOption;
         this.offset = (float)(10 + desiredSize.Height + 10);
     }
 }
开发者ID:nikolay-diyanov,项目名称:ios-sdk,代码行数:33,代码来源:ExampleViewController.cs

示例2: RenderAvailability

		void RenderAvailability()
		{
			if (null == ViewModel.Availabilities || ViewModel.Availabilities.Length == 0) return;

			_boxes.AddSectionHeader("Tilgjengelighet");

			foreach (var availability in ViewModel.Availabilities)
			{
				var box = _boxes.StartBox();
				new LabelAndValue(box, "Filial", availability.Branch, true);
				new LabelAndValue(box, "Finnes på hylle", availability.Location);
				new LabelAndValue(box, "Avdeling", availability.Department);
				new LabelAndValue(box, "Samling", availability.Collection);

				var availabilityText = availability.AvailableCount + " av " + availability.TotalCount + " tilgjengelig for utlån.";

				if (availability.EstimatedAvailableDate.HasValue)
				{
					availabilityText += " Tidligst tilgjengelig " + availability.EstimatedAvailableText;
				}

				new LabelAndValue(box, "Tilgjengelighet", availabilityText, colspan : 3);

				var reserve = new UIButton();

				reserve.TouchUpInside += (s, e) => availability.PlaceHoldRequestCommand.Execute(null);

				var set = this.CreateBindingSet<MediaDetailView, MediaDetailViewModel>();
				set.Bind(reserve).For("Title").To(vm => vm.ButtonText);
				set.Bind(reserve).For("Enabled").To(vm => vm.ButtonEnabled);
				set.Apply();


				Application.ThemeColors.Style(reserve);

				var btnPadding = UIHelpers.MinVersion7 ? 0f : padding;

				reserve.Frame = new RectangleF(padding, box.Subviews.Last().Frame.Bottom+padding, 165f, reserve.SizeThatFits(new SizeF(0f,0f)).Height + btnPadding);

				box.Add(reserve);
				box.Frame = new RectangleF(box.Frame.Location, new SizeF(box.Frame.Width, reserve.Frame.Bottom+padding));

			}
		}
开发者ID:khellang,项目名称:Solvberget,代码行数:44,代码来源:MediaDetailView.cs


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