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


C# UIView.AddConstraints方法代码示例

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


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

示例1: LoadView

		public override void LoadView ()
		{
			View = new UIView ();
			View.BackgroundColor = UIColor.White;

			var imageView = new UIImageView ();
			imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
			imageView.TranslatesAutoresizingMaskIntoConstraints = false;
			ImageView = imageView;
			View.Add (ImageView);

			var ratingControl = new RatingControl ();
			ratingControl.TranslatesAutoresizingMaskIntoConstraints = false;
			ratingControl.AddTarget (RatingChanges, UIControlEvent.ValueChanged);
			RatingControl = ratingControl;
			View.Add (RatingControl);

			var overlayButton = new OverlayView ();
			overlayButton.TranslatesAutoresizingMaskIntoConstraints = false;
			OverlayButton = overlayButton;
			View.Add (OverlayButton);

			UpdatePhoto ();

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("|[imageView]|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"imageView", imageView));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|[imageView]|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"imageView", imageView));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("[ratingControl]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"ratingControl", ratingControl));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("[overlayButton]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"overlayButton", overlayButton));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:[overlayButton]-[ratingControl]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"overlayButton", overlayButton,
				"ratingControl", ratingControl));

			var constraints = new List<NSLayoutConstraint> ();

			constraints.AddRange (NSLayoutConstraint.FromVisualFormat ("|-(>=20)-[ratingControl]",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"ratingControl", ratingControl));

			constraints.AddRange (NSLayoutConstraint.FromVisualFormat ("|-(>=20)-[overlayButton]",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"overlayButton", overlayButton));

			foreach (var constraint in constraints)
				constraint.Priority = (int)UILayoutPriority.Required - 1;

			View.AddConstraints (constraints.ToArray ());
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:60,代码来源:PhotoViewController.cs

示例2: LoadView

		public override void LoadView ()
		{
			UIView view = new UIView ();
			view.BackgroundColor = UIColor.White;

			gameView = new TTTGameView () {
				ImageForPlayer = ImageForPlayer,
				ColorForPlayer = ColorForPlayer,
				UserInteractionEnabled = false,
				TranslatesAutoresizingMaskIntoConstraints = false
			};

			view.AddSubview (gameView);
			gameView.Game = Game;

			nfloat topHeight = UIApplication.SharedApplication.StatusBarFrame.Size.Height +
				NavigationController.NavigationBar.Frame.Size.Height;

			view.AddConstraints (NSLayoutConstraint.FromVisualFormat ("|-margin-[gameView]-margin-|",
				(NSLayoutFormatOptions)0,
				"margin", Margin,
				"gameView", gameView));

			view.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-topHeight-[gameView]-bottomHeight-|",
				(NSLayoutFormatOptions)0,
				"topHeight", topHeight + Margin,
				"gameView", gameView,
				"bottomHeight", Margin));

			View = view;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:31,代码来源:TTTGameHistoryViewController.cs

示例3: LoadView

		public override void LoadView ()
		{
			UIView baseView = new UIView ();
			baseView.BackgroundColor = UIColor.FromWhiteAlpha (0f, .15f);

			UIView view = new UIView (new RectangleF (-100f, -50f, 240f, 120f)) {
				AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin |
				UIViewAutoresizing.FlexibleBottomMargin |
				UIViewAutoresizing.FlexibleTopMargin |
				UIViewAutoresizing.FlexibleRightMargin,
				BackgroundColor = UIColor.FromPatternImage (UIImage.FromBundle ("barBackground"))
			};
			baseView.AddSubview (view);

			UIButton cancelButton = UIButton.FromType (UIButtonType.System);
			cancelButton.TouchUpInside += close;
			cancelButton.TranslatesAutoresizingMaskIntoConstraints = false;
			cancelButton.SetTitle ("Cancel", UIControlState.Normal);
			view.AddSubview (cancelButton);

			UIButton postButton = UIButton.FromType (UIButtonType.System);
			postButton.TouchUpInside += post;
			postButton.TranslatesAutoresizingMaskIntoConstraints = false;
			postButton.SetTitle ("Post", UIControlState.Normal);
			view.AddSubview (postButton);

			messageTextView = new UITextView () {
				BackgroundColor = UIColor.Clear,
				TranslatesAutoresizingMaskIntoConstraints = false
			};
			view.AddSubview (messageTextView);

			NSDictionary views = NSDictionary.FromObjectsAndKeys (
				new NSObject[] { postButton, cancelButton, messageTextView },
				new NSString[] { new NSString ("postButton"),
				new NSString ("cancelButton"),
				new NSString ("messageTextView")
			}
			);

			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-8-[messageTextView]-8-|", (NSLayoutFormatOptions)0, null, views)
			);
			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-8-[cancelButton]->=20-[postButton]-8-|", (NSLayoutFormatOptions)0, null, views)
			);
			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-8-[messageTextView]-[cancelButton]-8-|", (NSLayoutFormatOptions)0, null, views)
			);
			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-8-[messageTextView]-[postButton]-8-|", (NSLayoutFormatOptions)0, null, views)
			);

			View = baseView;
		}
开发者ID:nowayy,项目名称:monotouch-samples,代码行数:55,代码来源:TTTNewMessageViewController.cs

示例4: LoadView

        public override void LoadView ()
        {
            var view = new UIView ().Apply (Style.Screen);

            view.Add (nameTextField = new TextField () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "NewProjectNameHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            } .Apply (Style.NewProject.NameField));
            nameTextField.EditingChanged += (sender, e) => ValidateProjectName ();

            view.Add (clientButton = new UIButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            } .Apply (Style.NewProject.ClientButton).Apply (Style.NewProject.NoClient));
            clientButton.SetTitle ("NewProjectClientHint".Tr (), UIControlState.Normal);
            clientButton.TouchUpInside += OnClientButtonTouchUpInside;

            view.AddConstraints (VerticalLinearLayout (view));

            EdgesForExtendedLayout = UIRectEdge.None;
            View = view;

            var addBtn = new UIBarButtonItem (
                "NewProjectAdd".Tr (), UIBarButtonItemStyle.Plain, OnSetBtnPressed)
            .Apply (Style.NavLabelButton).Apply (Style.DisableNavLabelButton);
            addBtn.Enabled = false;
            NavigationItem.RightBarButtonItem = addBtn;
        }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:31,代码来源:NewProjectViewController.cs

示例5: LoadView

        public override void LoadView ()
        {
            var view = new UIView ().Apply (Style.Screen);

            view.Add (nameTextField = new TextField () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "NewProjectNameHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            }.Apply (Style.NewProject.NameField).Apply (BindNameField));
            nameTextField.EditingChanged += OnNameFieldEditingChanged;

            view.Add (clientButton = new UIButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.NewProject.ClientButton).Apply (BindClientButton));
            clientButton.TouchUpInside += OnClientButtonTouchUpInside;

            view.AddConstraints (VerticalLinearLayout (view));

            EdgesForExtendedLayout = UIRectEdge.None;
            View = view;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem (
                "NewProjectAdd".Tr (), UIBarButtonItemStyle.Plain, OnNavigationBarAddClicked)
                .Apply (Style.NavLabelButton);
        }
开发者ID:nagyist,项目名称:toggl-mobile,代码行数:28,代码来源:NewProjectViewController.cs

示例6: LoadView

        public override void LoadView ()
        {
            View = new UIView ().Apply (Style.Screen);

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (askProjectView = new LabelSwitchView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.RowBackground).Apply (BindAskProjectView));
            askProjectView.Label.Apply (Style.Settings.SettingLabel);
            askProjectView.Label.Text = "SettingsAskProject".Tr ();
            askProjectView.Switch.ValueChanged += OnAskProjectViewValueChanged;

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (new UILabel () {
                Text = "SettingsAskProjectDesc".Tr (),
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.DescriptionLabel));

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (mobileTagView = new LabelSwitchView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.RowBackground).Apply (BindMobileTagView));
            mobileTagView.Label.Apply (Style.Settings.SettingLabel);
            mobileTagView.Label.Text = "SettingsMobileTag".Tr ();
            mobileTagView.Switch.ValueChanged += OnMobileTagViewValueChanged;

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (new UILabel () {
                Text = "SettingsMobileTagDesc".Tr (),
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.DescriptionLabel));

            View.AddConstraints (MakeConstraints (View));
        }
开发者ID:nagyist,项目名称:toggl-mobile,代码行数:34,代码来源:SettingsViewController.cs

示例7: LoadView

		public override void LoadView ()
		{
			UIView view = new UIView ();
			view.BackgroundColor = UIColor.White;

			gameView = new TTTGameView () {
				ImageForPlayer = ImageForPlayer,
				ColorForPlayer = ColorForPlayer,
				UserInteractionEnabled = false,
				TranslatesAutoresizingMaskIntoConstraints = false
			};

			view.AddSubview (gameView);
			gameView.Game = Game;

			float topHeight = UIApplication.SharedApplication.StatusBarFrame.Size.Height +
				NavigationController.NavigationBar.Frame.Size.Height;
			NSDictionary bindings = NSDictionary.FromObjectAndKey (gameView, new NSString ("gameView"));
			NSDictionary metrics = NSDictionary.FromObjectsAndKeys (
				new NSObject[] { new NSNumber (topHeight + Margin),
				new NSNumber (Margin), new NSNumber (Margin)
			},
				new NSString [] { 
				new NSString ("topHeight"), 
				new NSString ("bottomHeight"),
				new NSString ("margin")
			});

			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-margin-[gameView]-margin-|", (NSLayoutFormatOptions)0,
				metrics, bindings));
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-topHeight-[gameView]-bottomHeight-|", (NSLayoutFormatOptions)0,
				metrics, bindings));

			View = view;
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:37,代码来源:TTTGameHistoryViewController.cs

示例8: UICustomProgressView

        public UICustomProgressView()
        {
            currentProgressLabel = new UILabel();
            currentProgressLabel.Text = "10000000";

            ofProgressLabel = new UILabel();
            ofProgressLabel.Text = "of";

            totalProgressLabel = new UILabel();
            totalProgressLabel.Text = "10000000";

            progressNoContainer = new UIView();
            progressNoContainer.BackgroundColor = UIColor.Yellow;
            progressNoContainer.Layer.BorderColor = UIColor.Red.CGColor;
            progressNoContainer.Layer.BorderWidth = 2f;

            progressNoContainer.AddSubviews(new UIView[] { currentProgressLabel, ofProgressLabel, totalProgressLabel });
            progressNoContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            progressNoContainer.AddConstraints(new[]
            {
                currentProgressLabel.AtTopOf(progressNoContainer),
                currentProgressLabel.WithSameCenterX(progressNoContainer).Minus(25),
                currentProgressLabel.Height().EqualTo(30),

                ofProgressLabel.WithSameTop(currentProgressLabel),
                ofProgressLabel.ToRightOf(currentProgressLabel).Plus(5),
                ofProgressLabel.WithSameHeight(currentProgressLabel),

                totalProgressLabel.WithSameBottom(ofProgressLabel),
                totalProgressLabel.ToRightOf(ofProgressLabel).Plus(5),
                totalProgressLabel.WithSameHeight(ofProgressLabel)
            });

            AddSubviews(new[] { progressNoContainer });
            this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            this.AddConstraints(new[]
            {
                progressNoContainer.WithSameCenterY(this),
                progressNoContainer.WithSameRight(this).Minus(10),
                progressNoContainer.Width().EqualTo(100),
                progressNoContainer.Height().EqualTo(30)
            });
        }
开发者ID:raghurana,项目名称:NsUrlDownloadDemo,代码行数:43,代码来源:UICustomProgressView.cs

示例9: LoadView

        public override void LoadView ()
        {
            var view = new UIView ().Apply (Style.Screen);

            view.Add (NameTextField = new TextField {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "NewClientNameHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            } .Apply (Style.NewProject.NameField));

            NameTextField.EditingChanged += (sender, e) => ValidateClientName ();
            view.AddConstraints (VerticalLinearLayout (view));
            EdgesForExtendedLayout = UIRectEdge.None;
            View = view;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem (
                "NewClientAdd".Tr (), UIBarButtonItemStyle.Plain, OnNavigationBarAddClicked)
            .Apply (Style.DisableNavLabelButton);
            NavigationItem.RightBarButtonItem.Enabled = false;
        }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:23,代码来源:NewClientViewController.cs

示例10: LoadView

        public override void LoadView ()
        {
            View = new UIView ()
                .Apply (Style.Screen);

            View.Add (inputsContainer = new UIView ().Apply (Style.Login.InputsContainer));

            inputsContainer.Add (topBorder = new UIView ().Apply (Style.Login.InputsBorder));

            inputsContainer.Add (emailTextField = new UITextField () {
                Placeholder = "LoginEmailHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType = UIKeyboardType.EmailAddress,
                ReturnKeyType = UIReturnKeyType.Next,
                ClearButtonMode = UITextFieldViewMode.Always,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Login.EmailField));

            inputsContainer.Add (middleBorder = new UIView ().Apply (Style.Login.InputsBorder));

            inputsContainer.Add (passwordTextField = new UITextField () {
                Placeholder = "LoginPasswordHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                SecureTextEntry = true,
                ReturnKeyType = UIReturnKeyType.Go,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Login.PasswordField));

            inputsContainer.Add (bottomBorder = new UIView ().Apply (Style.Login.InputsBorder));

            View.Add (passwordActionButton = new UIButton ()
                .Apply (Style.Login.LoginButton));
            passwordActionButton.SetTitle ("LoginLoginButtonText".Tr (), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            inputsContainer.AddConstraints (
                topBorder.AtTopOf (inputsContainer),
                topBorder.AtLeftOf (inputsContainer),
                topBorder.AtRightOf (inputsContainer),
                topBorder.Height ().EqualTo (1f),

                emailTextField.Below (topBorder),
                emailTextField.AtLeftOf (inputsContainer, 20f),
                emailTextField.AtRightOf (inputsContainer, 10f),
                emailTextField.Height ().EqualTo (42f),

                middleBorder.Below (emailTextField),
                middleBorder.AtLeftOf (inputsContainer, 20f),
                middleBorder.AtRightOf (inputsContainer),
                middleBorder.Height ().EqualTo (1f),

                passwordTextField.Below (middleBorder),
                passwordTextField.AtLeftOf (inputsContainer, 20f),
                passwordTextField.AtRightOf (inputsContainer),
                passwordTextField.Height ().EqualTo (42f),

                bottomBorder.Below (passwordTextField),
                bottomBorder.AtLeftOf (inputsContainer),
                bottomBorder.AtRightOf (inputsContainer),
                bottomBorder.AtBottomOf (inputsContainer),
                bottomBorder.Height ().EqualTo (1f)
            );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            View.AddConstraints (
                inputsContainer.AtTopOf (View, 80f),
                inputsContainer.AtLeftOf (View),
                inputsContainer.AtRightOf (View),

                passwordActionButton.Below (inputsContainer, 20f),
                passwordActionButton.AtLeftOf (View),
                passwordActionButton.AtRightOf (View),
                passwordActionButton.Height ().EqualTo (60f)
            );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();
        }
开发者ID:nagyist,项目名称:toggl-mobile,代码行数:79,代码来源:LoginViewController.cs

示例11: LoadView

        public override void LoadView ()
        {
            View = new UIView ()
                .Apply (Style.Screen);

            View.Add (inputsContainer = new UIView ().Apply (Style.Signup.InputsContainer));

            inputsContainer.Add (topBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            inputsContainer.Add (emailTextField = new UITextField () {
                Placeholder = "SignupEmailHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType = UIKeyboardType.EmailAddress,
                ReturnKeyType = UIReturnKeyType.Next,
                ClearButtonMode = UITextFieldViewMode.Always,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Signup.EmailField));
            emailTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add (middleBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            inputsContainer.Add(passwordTextField = new PasswordTextField () {
                Placeholder = "SignupPasswordHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                SecureTextEntry = true,
                ReturnKeyType = UIReturnKeyType.Go,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Signup.PasswordField));
            passwordTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add (bottomBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            View.Add (passwordActionButton = new UIButton ()
                .Apply (Style.Signup.SignupButton));
            passwordActionButton.SetTitle ("SignupSignupButtonText".Tr (), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            View.Add (googleActionButton = new UIButton ()
                .Apply (Style.Signup.GoogleButton));
            googleActionButton.SetTitle ("SignupGoogleButtonText".Tr (), UIControlState.Normal);
            googleActionButton.TouchUpInside += OnGoogleActionButtonTouchUpInside;

            View.Add (legalLabel = new TTTAttributedLabel () {
                Delegate = new LegalLabelDelegate (),
            }.Apply (Style.Signup.LegalLabel));
            SetLegalText (legalLabel);

            inputsContainer.AddConstraints (
                topBorder.AtTopOf (inputsContainer),
                topBorder.AtLeftOf (inputsContainer),
                topBorder.AtRightOf (inputsContainer),
                topBorder.Height ().EqualTo (1f),

                emailTextField.Below (topBorder),
                emailTextField.AtLeftOf (inputsContainer, 20f),
                emailTextField.AtRightOf (inputsContainer, 10f),
                emailTextField.Height ().EqualTo (42f),

                middleBorder.Below (emailTextField),
                middleBorder.AtLeftOf (inputsContainer, 20f),
                middleBorder.AtRightOf (inputsContainer),
                middleBorder.Height ().EqualTo (1f),

                passwordTextField.Below (middleBorder),
                passwordTextField.AtLeftOf (inputsContainer, 20f),
                passwordTextField.AtRightOf (inputsContainer),
                passwordTextField.Height ().EqualTo (42f),

                bottomBorder.Below (passwordTextField),
                bottomBorder.AtLeftOf (inputsContainer),
                bottomBorder.AtRightOf (inputsContainer),
                bottomBorder.AtBottomOf (inputsContainer),
                bottomBorder.Height ().EqualTo (1f)
            );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            View.AddConstraints (
                inputsContainer.AtTopOf (View, 80f),
                inputsContainer.AtLeftOf (View),
                inputsContainer.AtRightOf (View),

                passwordActionButton.Below (inputsContainer, 20f),
                passwordActionButton.AtLeftOf (View),
                passwordActionButton.AtRightOf (View),
                passwordActionButton.Height ().EqualTo (60f),

                googleActionButton.Below (passwordActionButton, 5f),
                googleActionButton.AtLeftOf (View),
                googleActionButton.AtRightOf (View),
                googleActionButton.Height ().EqualTo (60f),

                legalLabel.AtBottomOf (View, 30f),
                legalLabel.AtLeftOf (View, 40f),
                legalLabel.AtRightOf (View, 40f)
            );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

//.........这里部分代码省略.........
开发者ID:jblj,项目名称:mobile,代码行数:101,代码来源:SignupViewController.cs

示例12: LoadView

		public override void LoadView ()
		{
			UIView view = new UIView ();

			UIButton newButton = UIButton.FromType (UIButtonType.System);
			newButton.TranslatesAutoresizingMaskIntoConstraints = false;
			newButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
			newButton.SetTitle ("New Game", UIControlState.Normal);
			newButton.TitleLabel.Font = UIFont.PreferredBody;
			newButton.TouchUpInside += newGame;
			view.AddSubview (newButton);

			UIButton pauseButton = UIButton.FromType (UIButtonType.System);
			pauseButton.TranslatesAutoresizingMaskIntoConstraints = false;
			pauseButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
			pauseButton.SetTitle ("Pause", UIControlState.Normal);
			pauseButton.TitleLabel.Font = UIFont.PreferredBody;
			pauseButton.TouchUpInside += togglePause;
			view.AddSubview (pauseButton);

			gameView = new TTTGameView () {
				ImageForPlayer = ImageForPlayer,
				ColorForPlayer = ColorForPlayer,
				CanSelect = CanSelect,
				DidSelect = DidSelect,
				TranslatesAutoresizingMaskIntoConstraints = false,
				Game = Profile.CurrentGame
			};
			view.AddSubview (gameView);

			float topHeight = UIApplication.SharedApplication.StatusBarFrame.Size.Height;
			UITabBar tabBar = TabBarController.TabBar;
			float bottomHeight = tabBar.Translucent ? tabBar.Frame.Size.Height : 0;
			NSDictionary metrics = NSDictionary.FromObjectsAndKeys (
				new NSNumber[] { new NSNumber (topHeight + ControllerMargin),
				new NSNumber (bottomHeight + ControllerMargin),
				new NSNumber (ControllerMargin)
			},
				new NSString[] { new NSString ("topHeight"), new NSString ("bottomHeight"),
				new NSString ("margin")
			}
			);
			NSDictionary bindings = NSDictionary.FromObjectsAndKeys (
				new NSObject[] { newButton, pauseButton, gameView },
				new NSString [] { 
				new NSString ("newButton"), new NSString ("pauseButton"),
				new NSString ("gameView")
			}
			);
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-margin-[gameView]-margin-|", (NSLayoutFormatOptions)0,
				metrics, bindings
			));
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-margin-[pauseButton(==newButton)]-[newButton]-margin-|",
				(NSLayoutFormatOptions)0, metrics, bindings
			));
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-topHeight-[gameView]-margin-[newButton]-bottomHeight-|",
				(NSLayoutFormatOptions)0, metrics, bindings
			));
			view.AddConstraint (NSLayoutConstraint.Create (pauseButton,
			                                               NSLayoutAttribute.Baseline,
			                                               NSLayoutRelation.Equal,
			                                               newButton,
			                                               NSLayoutAttribute.Baseline,
			                                               1f,
			                                               0f));

			View = view;
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:71,代码来源:TTTPlayViewController.cs

示例13: ConstructDateTimeView

            private static void ConstructDateTimeView (UIView view, ref UILabel dateLabel, ref UILabel timeLabel)
            {
                view.Add (dateLabel = new UILabel ().Apply (Style.EditTimeEntry.DateLabel));
                view.Add (timeLabel = new UILabel ().Apply (Style.EditTimeEntry.TimeLabel));
                view.AddConstraints (
                    dateLabel.AtTopOf (view, 10f),
                    dateLabel.AtLeftOf (view, 10f),
                    dateLabel.AtRightOf (view, 10f),

                    timeLabel.Below (dateLabel, 2f),
                    timeLabel.AtBottomOf (view, 10f),
                    timeLabel.AtLeftOf (view, 10f),
                    timeLabel.AtRightOf (view, 10f)
                );
                view.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();
            }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:16,代码来源:EditTimeEntryViewController.cs

示例14: InitializeControls

        void InitializeControls()
        {
            View.BackgroundColor = UIColor.Clear;
            _internalView = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _headerLabel = new UILabel {
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                BackgroundColor = HeaderBackgroundColor,
                TextColor = HeaderTextColor,
                Text = HeaderText,
                TextAlignment = UITextAlignment.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _cancelButton = UIButton.FromType(UIButtonType.System);
            _cancelButton.SetTitleColor(HeaderTextColor, UIControlState.Normal);
            _cancelButton.BackgroundColor = UIColor.Clear;
            _cancelButton.SetTitle(CancelButtonText, UIControlState.Normal);
            _cancelButton.TouchUpInside += CancelButtonTapped;
            _cancelButton.TranslatesAutoresizingMaskIntoConstraints = false;
            AddButtonSizeConstraints (_cancelButton);

            _doneButton = UIButton.FromType(UIButtonType.System);
            _doneButton.SetTitleColor(HeaderTextColor, UIControlState.Normal);
            _doneButton.BackgroundColor = UIColor.Clear;
            _doneButton.SetTitle(DoneButtonText, UIControlState.Normal);
            _doneButton.TouchUpInside += DoneButtonTapped;
            _doneButton.TranslatesAutoresizingMaskIntoConstraints = false;
            AddButtonSizeConstraints (_doneButton);

            UIView picker = null;
            switch(PickerType)
            {
                case ModalPickerType.Date:
                    picker = DatePicker;
                    break;
                case ModalPickerType.Custom:
                    picker = PickerView;
                    break;
                default:
                    break;
            }
            picker.BackgroundColor = UIColor.White;
            _internalView.AddSubview (picker);
            _internalView.BackgroundColor = HeaderBackgroundColor;

            _internalView.AddSubview(_headerLabel);
            _internalView.AddSubview (_cancelButton);
            _internalView.AddSubview(_doneButton);

            _internalView.AddConstraints (new[] {
                NSLayoutConstraint.Create (_cancelButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.Top, 1f, 7f),
                NSLayoutConstraint.Create (_cancelButton, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.Leading, 1f, 10f),
                NSLayoutConstraint.Create (_headerLabel, NSLayoutAttribute.Baseline, NSLayoutRelation.Equal, _cancelButton, NSLayoutAttribute.Baseline, 1f, 0f),
                NSLayoutConstraint.Create (_headerLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _cancelButton, NSLayoutAttribute.Trailing, 1f, 10f),
                NSLayoutConstraint.Create (_doneButton, NSLayoutAttribute.Baseline, NSLayoutRelation.Equal, _headerLabel, NSLayoutAttribute.Baseline, 1f, 0f),
                NSLayoutConstraint.Create (_doneButton, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _headerLabel, NSLayoutAttribute.Trailing, 1f, 10f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _doneButton, NSLayoutAttribute.Trailing, 1f, 10f),
                NSLayoutConstraint.Create (picker, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.CenterX, 1f, 0f),
                NSLayoutConstraint.Create (picker, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.Bottom, 1f, 0f),
                NSLayoutConstraint.Create (picker, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _cancelButton, NSLayoutAttribute.Bottom, 1f, 5f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, picker, NSLayoutAttribute.Width, 1f, 0f),
            });

            Add(_internalView);
            View.AddConstraints (new[] {
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f)
            });
        }
开发者ID:morpheusllc,项目名称:ModalPickerViewController,代码行数:73,代码来源:ModalPickerViewController.cs

示例15: LoadView

        public override void LoadView ()
        {
            base.LoadView ();

            isUserLogged = UserDefaults.BoolForKey (IsUserLoggedKey);
            isAppActive = UserDefaults.BoolForKey (AppActiveEntryKey);
            isAppOnBackground = UserDefaults.BoolForKey (AppBackgroundEntryKey);

            marginTop = (isUserLogged && isAppActive) ? 10f : 1f;
            height = (isUserLogged && isAppActive) ? 250f : 62f; // 4 x 60f(cells),

            var v = new UIView {
                BackgroundColor = UIColor.Clear,
                Frame = new CGRect (0,0, UIScreen.MainScreen.Bounds.Width, height),
            };

            v.Add (tableView = new UITableView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear,
                TableFooterView = new UIView(),
                ScrollEnabled = false,
                RowHeight = cellHeight,
            });

            v.Add (openAppView = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Hidden = true,
            });

            UIView bg;
            openAppView.Add (bg = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Black,
                Alpha = 0.1f,
            });

            UILabel textView;
            openAppView.Add (textView = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromName ("Helvetica", 13f),
                Text = isAppActive ? "NoLoggedUser".Tr() : "NoActiveApp".Tr(),
                TextColor = UIColor.White,
                BackgroundColor = UIColor.Clear,
            });

            openAppView.Add (openAppBtn = new StartStopBtn {
                TranslatesAutoresizingMaskIntoConstraints = false,
                IsActive = true,
            });

            openAppView.AddConstraints (

                bg.AtTopOf (openAppView),
                bg.AtLeftOf (openAppView),
                bg.AtRightOf (openAppView),
                bg.AtBottomOf (openAppView),

                textView.WithSameCenterY (openAppView),
                textView.AtLeftOf (openAppView, 50f),
                textView.WithSameHeight (openAppView),
                textView.AtRightOf (openAppView),

                openAppBtn.Width().EqualTo (35f),
                openAppBtn.Height().EqualTo (35f),
                openAppBtn.AtRightOf (openAppView, 15f),
                openAppBtn.WithSameCenterY (openAppView),

                null
            );

            v.AddConstraints (

                tableView.AtTopOf (v),
                tableView.WithSameWidth (v),
                tableView.Height().EqualTo (height - marginTop).SetPriority (UILayoutPriority.DefaultLow),
                tableView.AtBottomOf (v),

                openAppView.AtTopOf (v),
                openAppView.WithSameWidth (v),
                openAppView.Height().EqualTo (cellHeight),

                null
            );

            View = v;
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:86,代码来源:WidgetViewController.cs


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