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


C# UIButton.CenterX方法代码示例

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


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

示例1: ShowView

		private void ShowView(){

			_image = new UIImageView ();
			_image.Image = UIImage.FromBundle("logo.png");
			View.Add (_image);

			_username = new UITextField ();
			_username.Placeholder = _loginViewModel.Localaizer.Localize("username");
			_username.TextAlignment = UITextAlignment.Center;
			View.Add (_username);

			_password = new UITextField ();
			_password.Placeholder = _loginViewModel.Localaizer.Localize("password");
			_password.TextAlignment = UITextAlignment.Center;
			_password.SecureTextEntry = true;
			View.Add (_password);

			_loginBtn = new UIButton ();
			_loginBtn.SetTitle(_loginViewModel.Localaizer.Localize("login"), UIControlState.Normal);
			_loginBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			View.Add (_loginBtn);
		
			_error = new UILabel ();
			_error.Lines = 0;
			_error.LineBreakMode = UILineBreakMode.WordWrap;
			_error.TextColor = UIColor.Red;
			_error.TextAlignment = UITextAlignment.Center;
			View.Add (_error);

			View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();
			var screen = UIScreen.MainScreen.Bounds;
			var screenWidth = (float)screen.Width;
			//var screenHeight = (float)screen.Height;

			View.AddConstraints (
				_image.Top().EqualTo().TopOf(View).Plus(screenWidth/4),
				_image.CenterX().EqualTo().CenterXOf(View),
				_image.Width().LessThanOrEqualTo(200),
				_image.Height().LessThanOrEqualTo(140),

				_username.Top().EqualTo().BottomOf(_image),
				_username.CenterX().EqualTo().CenterXOf(View),

				_password.Top().EqualTo().BottomOf(_username),
				_password.CenterX().EqualTo().CenterXOf(View),

				_loginBtn.Top().EqualTo().BottomOf(_password),
				_loginBtn.CenterX().EqualTo().CenterXOf(View),

				_error.Top().EqualTo().BottomOf(_loginBtn),
				_error.CenterX().EqualTo().CenterXOf(View),
				_error.Width().LessThanOrEqualTo(screenWidth)
			);
		}
开发者ID:dtimyr,项目名称:xamarin,代码行数:54,代码来源:LoginViewController.cs

示例2: CreateView

		private void CreateView(string title, int tag, CustomUIViewController TabViewController){

			TabViewController.View = new UIView ();
			TabViewController.View.BackgroundColor = UIColor.White;

			var vacationType = new UILabel ();
			vacationType.Text = title;

			TabViewController.View.Add (vacationType);

			var vacationStartDate = new UILabel ();
			vacationStartDate.Text = _localizer.Localize("startDate");
			TabViewController.View.Add (vacationStartDate);

			var vacationStartDateBtn = new UIButton ();
			vacationStartDateBtn.SetTitle(DateTime.Now.ToString("d"), UIControlState.Normal);
			vacationStartDateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			vacationStartDateBtn.Tag = STARTDATE_TAG + tag;
			TabViewController.View.Add (vacationStartDateBtn);

			var vacationEndDate = new UILabel ();
			vacationEndDate.Text = _localizer.Localize("endDate");
			TabViewController.View.Add (vacationEndDate);

			var vacationEndDateBtn = new UIButton ();
			vacationEndDateBtn.SetTitle(DateTime.Now.ToString("d"), UIControlState.Normal);
			vacationEndDateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			vacationEndDateBtn.Tag = ENDDATE_TAG + tag;
			TabViewController.View.Add (vacationEndDateBtn);

			var vacationError = new UILabel ();
			vacationError.Text = "";
			vacationError.TextColor = UIColor.Red;
			vacationError.Lines = 0;
			vacationError.LineBreakMode = UILineBreakMode.WordWrap;
			vacationError.Tag = ERROR_TAG + tag;
			TabViewController.View.Add (vacationError);

			var vacationPickImageFromGallery = new UIButton ();
			vacationPickImageFromGallery.SetTitle(_localizer.Localize("pickImgFromGallery"), UIControlState.Normal);
			vacationPickImageFromGallery.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			vacationPickImageFromGallery.Tag = PICKIMAGE_TAG + tag;
			TabViewController.View.Add (vacationPickImageFromGallery);

			var vacationImageView = new UIImageView ();
			vacationImageView.Tag  = IMAGE_TAG + tag;
			TabViewController.View.Add (vacationImageView);

			var vacationCreateBtn = new UIButton ();
			vacationCreateBtn.SetTitle(_localizer.Localize("create"), UIControlState.Normal);
			vacationCreateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			vacationCreateBtn.Tag = CREATE_TAG + tag;
			TabViewController.View.Add (vacationCreateBtn);


			TabViewController.View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

			var screen = UIScreen.MainScreen.Bounds;
			var screenWidth = (float)screen.Width;
			var screenHeight = (float)screen.Height;

			if (InterfaceOrientation == UIInterfaceOrientation.Portrait) {
				TabViewController.View.AddConstraints (
					vacationType.Top().EqualTo().TopOf(TabViewController.View).Plus(screenWidth/2),
					vacationType.CenterX().EqualTo().CenterXOf(TabViewController.View)
				);
			} else {
				TabViewController.View.AddConstraints (
					vacationType.Top().EqualTo().TopOf(TabViewController.View).Plus(50),
					vacationType.CenterX().EqualTo().CenterXOf(TabViewController.View)
				);
			}

			TabViewController.View.AddConstraints (

				vacationStartDate.Top().EqualTo().BottomOf(vacationType).Plus(10),
				vacationStartDate.CenterX().EqualTo().CenterXOf(TabViewController.View).Minus(70),
				vacationStartDate.Left().EqualTo().LeftOf(TabViewController.View).Plus(5),

				vacationStartDateBtn.Top().EqualTo().BottomOf(vacationType).Plus(3),
				vacationStartDateBtn.Right().EqualTo().RightOf(TabViewController.View).Minus(5),

				vacationEndDate.Top().EqualTo().BottomOf(vacationStartDateBtn).Plus(3),
				vacationEndDate.CenterX().EqualTo().CenterXOf(TabViewController.View).Minus(70),
				vacationEndDate.Left().EqualTo().LeftOf(TabViewController.View).Plus(5),

				vacationEndDateBtn.Top().EqualTo().BottomOf(vacationStartDateBtn).Minus(5),
				vacationEndDateBtn.Right().EqualTo().RightOf(TabViewController.View).Minus(5),

				vacationCreateBtn.Top().EqualTo().BottomOf(vacationEndDate).Plus(5),
				vacationCreateBtn.CenterX().EqualTo().CenterXOf(TabViewController.View),

				vacationError.Top().EqualTo().BottomOf(vacationCreateBtn),
				vacationError.CenterX().EqualTo().CenterXOf(TabViewController.View),
				vacationError.Width().LessThanOrEqualTo(screenWidth),

				vacationPickImageFromGallery.Top().EqualTo().BottomOf(vacationError).Minus(10),
				vacationPickImageFromGallery.CenterX().EqualTo().CenterXOf(TabViewController.View),

				vacationImageView.Top().EqualTo().TopOf(vacationPickImageFromGallery).Plus(30),
//.........这里部分代码省略.........
开发者ID:dtimyr,项目名称:xamarin,代码行数:101,代码来源:CreateViewController.cs

示例3: ShowView

		private void ShowView(){
		
			var startDate = (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds (VTSModelTmp.VTSModel.StartDate).ToLocalTime ();
			var endDate = (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds (VTSModelTmp.VTSModel.EndDate).ToLocalTime (); 

			_vacationType = new UILabel ();
			_vacationType.Text = VTSModelTmp.VTSModel.VacationType;
			View.Add (_vacationType);

			_vacationStartDate = new UILabel ();
			_vacationStartDate.Text = _localizer.Localize("startDate");
			View.Add (_vacationStartDate);

			_vacationStartDateBtn = new UIButton ();
			_vacationStartDateBtn.SetTitle(startDate.ToString("d"), UIControlState.Normal);
			_vacationStartDateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			View.Add (_vacationStartDateBtn);

			_vacationEndDate = new UILabel ();
			_vacationEndDate.Text = _localizer.Localize("endDate");
			View.Add (_vacationEndDate);

			_vacationEndDateBtn = new UIButton ();
			_vacationEndDateBtn.SetTitle(endDate.ToString("d"), UIControlState.Normal);
			_vacationEndDateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			View.Add (_vacationEndDateBtn);

			_vacationStatusTitle = new UILabel ();
			_vacationStatusTitle.Text = _localizer.Localize("status");
			View.Add (_vacationStatusTitle);

			_vacationStatus = new UILabel ();
			_vacationStatus.Text = _localizer.Localize("cancelled");
			View.Add (_vacationStatus);

			_vacationError = new UILabel ();
			_vacationError.Text = "";
			//_vacationError.Text = _localizer.Localize("dateError");
			_vacationError.LineBreakMode = UILineBreakMode.WordWrap;
			_vacationError.Lines = 0;  
			_vacationError.TextColor = UIColor.Red;
			View.Add (_vacationError);

			_vacationPickImageFromGallery = new UIButton ();
			_vacationPickImageFromGallery.SetTitle(_localizer.Localize("pickImgFromGallery"), UIControlState.Normal);
			_vacationPickImageFromGallery.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			View.Add (_vacationPickImageFromGallery);

			_vacationImageView = new UIImageView ();
			if (VTSModelTmp.VTSModel.Image != null) {
				NSData imageData = NSData.FromArray(VTSModelTmp.VTSModel.Image); 
				_vacationImageView.Image = UIImage.LoadFromData(imageData); 
			}
			View.Add (_vacationImageView);

			_vacationUpdateBtn = new UIButton ();
			_vacationUpdateBtn.SetTitle(_localizer.Localize("update"), UIControlState.Normal);
			_vacationUpdateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal);
			View.Add (_vacationUpdateBtn);


			View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

			var screen = UIScreen.MainScreen.Bounds;
			var screenWidth = (float)screen.Width;
			var screenHeight = (float)screen.Height;

			View.AddConstraints (
				_vacationType.Top().EqualTo().TopOf(View).Plus(screenHeight/5),
				_vacationType.CenterX().EqualTo().CenterXOf(View),

				_vacationStartDate.Top().EqualTo().BottomOf(_vacationType).Plus(10),
				_vacationStartDate.CenterX().EqualTo().CenterXOf(View).Minus(70),
				_vacationStartDate.Left().EqualTo().LeftOf(View).Plus(5),

				_vacationStartDateBtn.Top().EqualTo().BottomOf(_vacationType).Plus(3),
				_vacationStartDateBtn.Right().EqualTo().RightOf(View).Minus(5),

				_vacationEndDate.Top().EqualTo().BottomOf(_vacationStartDateBtn).Plus(3),
				_vacationEndDate.CenterX().EqualTo().CenterXOf(View).Minus(70),
				_vacationEndDate.Left().EqualTo().LeftOf(View).Plus(5),

				_vacationEndDateBtn.Top().EqualTo().BottomOf(_vacationStartDateBtn).Minus(5),
				_vacationEndDateBtn.Right().EqualTo().RightOf(View).Minus(5),

				_vacationStatusTitle.Top().EqualTo().BottomOf(_vacationEndDate).Plus(10),
				_vacationStatusTitle.CenterX().EqualTo().CenterXOf(View).Minus(50),
				_vacationStatusTitle.Left().EqualTo().LeftOf(View).Plus(5),

				_vacationStatus.Top().EqualTo().BottomOf(_vacationEndDateBtn).Plus(4),
				_vacationStatus.Right().EqualTo().RightOf(View).Minus(5)
			);

			if (VTSModelTmp.VTSModel.Status != "greenCircle.png") {

				View.AddConstraints (
					_vacationUpdateBtn.Top().EqualTo().BottomOf(_vacationStatusTitle),
					_vacationUpdateBtn.CenterX().EqualTo().CenterXOf(View),

					_vacationError.Top().EqualTo().BottomOf(_vacationUpdateBtn),
//.........这里部分代码省略.........
开发者ID:dtimyr,项目名称:xamarin,代码行数:101,代码来源:EditViewController.cs


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