コード例 #1
0
        private void InitializeControls()
        {
            Frame = new CoreGraphics.CGRect(0, 0, 44, 44);

            _imageView = new UIImageView()
                         .WithFrame(8, 8, 28, 28)
                         .WithTune(tune =>
            {
                tune.ClipsToBounds = true;
            });
            _imageView.AddConstraint(NSLayoutConstraint.Create(_imageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 28));
            _imageView.AddConstraint(NSLayoutConstraint.Create(_imageView, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1, 28));

            _badge = new AppRopio.Base.iOS.Controls.ARLabel();
            _badge.WithFrame(24, 4, 16, 16);
            _badge.WithTextAlignment(UITextAlignment.Center);
            _badge.TranslatesAutoresizingMaskIntoConstraints = false;
            _badge.AddConstraint(NSLayoutConstraint.Create(_badge, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 16));
            _badge.AddConstraint(NSLayoutConstraint.Create(_badge, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1, 16));

            SetupImage(_imageView);
            SetupLabel(_badge);

            AddSubviews(_imageView, _badge);

            AddConstraints(new[]
            {
                NSLayoutConstraint.Create(_badge, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 4),
                NSLayoutConstraint.Create(_badge, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, -4),
                NSLayoutConstraint.Create(_imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1, 0),
                NSLayoutConstraint.Create(_imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, 0)
            });
        }
コード例 #2
0
        private void SetupAppropioView()
        {
            this.AddConstraint(NSLayoutConstraint.Create(this, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 97.If_iPhoneX(127)));
            this.AddConstraint(NSLayoutConstraint.Create(this, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, UIScreen.MainScreen.Bounds.Width));

            var backgroundColor = Theme.ColorPalette.Background.ToUIColor();

            BackgroundColor = backgroundColor;

            var brightness = ((backgroundColor.CGColor.Components[0] * 299) + (backgroundColor.CGColor.Components[1] * 587) + (backgroundColor.CGColor.Components[2] * 114)) / 1000;

            var contentColor = brightness < 0.5f ? UIColor.White : UIColor.Black;

            AddSubviews(
                _appropioImage = new UIImageView(ImageCache.GetImage("Images/appropio_logo.png", contentColor))
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            },
                _appropioNameLabel = new UILabel()
            {
                AttributedText = new NSMutableAttributedString("APPROPIO", new UIStringAttributes {
                    KerningAdjustment = 5, ForegroundColor = contentColor, Font = (UIFont)Theme.FontsPalette.BoldOfSize(13)
                }),
                TranslatesAutoresizingMaskIntoConstraints = false
            },
                _appropioDevelopedLabel = new UILabel()
            {
                Font      = (UIFont)Theme.FontsPalette.MediumOfSize(10),
                TextColor = contentColor.ColorWithAlpha(0.3f),
                Text      = "designed by",
                TranslatesAutoresizingMaskIntoConstraints = false
            }
                );

            _appropioImage.AddConstraint(NSLayoutConstraint.Create(_appropioImage, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 34));
            _appropioImage.AddConstraint(NSLayoutConstraint.Create(_appropioImage, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 27));

            this.AddConstraints(new NSLayoutConstraint[]
            {
                NSLayoutConstraint.Create(_appropioImage, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 10),
                NSLayoutConstraint.Create(_appropioImage, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1, 0),

                NSLayoutConstraint.Create(_appropioNameLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _appropioImage, NSLayoutAttribute.Bottom, 1, 12),
                NSLayoutConstraint.Create(_appropioNameLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1, 0),

                NSLayoutConstraint.Create(_appropioDevelopedLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _appropioNameLabel, NSLayoutAttribute.Bottom, 1, 4),
                NSLayoutConstraint.Create(_appropioDevelopedLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1, 0),
            });
        }
コード例 #3
0
        public TTGSnackbar() : base(CoreGraphics.CGRect.FromLTRB(0, 0, 320, 44))
        {
            this.TranslatesAutoresizingMaskIntoConstraints = false;
            this.BackgroundColor     = UIColor.DarkGray;
            this.Layer.CornerRadius  = 4;
            this.Layer.MasksToBounds = true;

            SetupSafeAreaInsets();

            this.MessageLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor       = UIColor.White,
                Font            = UIFont.SystemFontOfSize(14),
                BackgroundColor = UIColor.Clear,
                LineBreakMode   = UILineBreakMode.WordWrap,
                TextAlignment   = UITextAlignment.Left,
                Lines           = 0
            };

            this.AddSubview(this.MessageLabel);

            IconImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear,
                ContentMode     = IconContentMode
            };

            this.AddSubview(IconImageView);

            this.ActionButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear
            };
            this.ActionButton.TitleLabel.Font = UIFont.SystemFontOfSize(14);
            this.ActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            this.ActionButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            this.ActionButton.TouchUpInside += (s, e) =>
            {
                // there is a chance that user doesn't want to do anything here, he simply wants to dismiss
                ActionBlock?.Invoke(this);
                Dismiss();
            };

            this.AddSubview(this.ActionButton);

            this.SecondActionButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear
            };
            this.SecondActionButton.TitleLabel.Font = UIFont.BoldSystemFontOfSize(14);
            this.SecondActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            this.SecondActionButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            this.SecondActionButton.TouchUpInside += (s, e) =>
            {
                SecondActionBlock?.Invoke(this);
                Dismiss();
            };

            this.AddSubview(this.SecondActionButton);

            this.seperateView = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Gray
            };

            this.AddSubview(this.seperateView);

            // Add constraints
            var hConstraints = NSLayoutConstraint.FromVisualFormat(
                "H:|-0-[iconImageView]-2-[messageLabel]-2-[seperateView(0.5)]-2-[actionButton(>=44@999)]-0-[secondActionButton(>=44@999)]-0-|",
                0,
                new NSDictionary(),
                NSDictionary.FromObjectsAndKeys(
                    new NSObject[] {
                IconImageView,
                MessageLabel,
                seperateView,
                ActionButton,
                SecondActionButton
            },
                    new NSObject[] {
                new NSString("iconImageView"),
                new NSString("messageLabel"),
                new NSString("seperateView"),
                new NSString("actionButton"),
                new NSString("secondActionButton")
            }
                    )
                );

            var vConstraintsForIconImageView = NSLayoutConstraint.FromVisualFormat(
                "V:|-2-[iconImageView]-2-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { IconImageView }, new NSObject[] { new NSString("iconImageView") })
                );

            var vConstraintsForMessageLabel = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[messageLabel]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { MessageLabel }, new NSObject[] { new NSString("messageLabel") })
                );

            var vConstraintsForSeperateView = NSLayoutConstraint.FromVisualFormat(
                "V:|-4-[seperateView]-4-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { seperateView }, new NSObject[] { new NSString("seperateView") })
                );

            var vConstraintsForActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[actionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { ActionButton }, new NSObject[] { new NSString("actionButton") })
                );

            var vConstraintsForSecondActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[secondActionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { SecondActionButton }, new NSObject[] { new NSString("secondActionButton") })
                );

            iconImageViewWidthConstraint = NSLayoutConstraint.Create(IconImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarIconImageViewWidth);

            actionButtonWidthConstraint = NSLayoutConstraint.Create(ActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            secondActionButtonWidthConstraint = NSLayoutConstraint.Create(SecondActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            //var vConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
            //"V:|-2-[activityIndicatorView]-2-|", 0,new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { activityIndicatorView }, new NSObject[] { new NSString("activityIndicatorView") })
            //);

            //todo fix constraint
            //var hConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
            //  //"H:[activityIndicatorView(activityIndicatorWidth)]-2-|",
            //  "H:[activityIndicatorView]-2-|",
            //  0,
            //  new NSDictionary(),
            //  NSDictionary.FromObjectsAndKeys(
            //      new NSObject[] {  activityIndicatorView },
            //                 new NSObject[] {  new NSString("activityIndicatorView") })
            //  //NSDictionary.FromObjectsAndKeys(new NSObject[] { activityIndicatorView }, new NSObject[] {  })
            //);

            IconImageView.AddConstraint(iconImageViewWidthConstraint);
            ActionButton.AddConstraint(actionButtonWidthConstraint);
            SecondActionButton.AddConstraint(secondActionButtonWidthConstraint);

            this.AddConstraints(hConstraints);
            this.AddConstraints(vConstraintsForIconImageView);
            this.AddConstraints(vConstraintsForMessageLabel);
            this.AddConstraints(vConstraintsForSeperateView);
            this.AddConstraints(vConstraintsForActionButton);
            this.AddConstraints(vConstraintsForSecondActionButton);
            //this.AddConstraints(vConstraintsForActivityIndicatorView);
            //this.AddConstraints(hConstraintsForActivityIndicatorView);
        }
コード例 #4
0
        private void UpdateImage(string imageName, int widthRequest, int heightRequest, UIButton targetButton)
        {
            var     assembly = typeof(App).GetTypeInfo().Assembly;
            UIImage image    = null;

            if (imageName != null)
            {
                try
                {
                    image = UIImage.FromResource(assembly, imageName);
                }
                catch (Exception)
                {
                    var path  = PCLStorage.FileSystem.Current.LocalStorage.Path;
                    var iPath = PCLStorage.PortablePath.Combine(path, imageName);
                    image = UIImage.FromFile(iPath);
                }
            }

            var imageView = new UIImageView();

            var widthCt  = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, widthRequest);
            var heightCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, heightRequest);

            imageView.AddConstraint(widthCt);
            imageView.AddConstraint(heightCt);
            imageView.TranslatesAutoresizingMaskIntoConstraints = false;
            imageView.Image       = image;
            imageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            targetButton.AddSubview(imageView);

            switch (ImageButton.Orientation)
            {
            case TextAligment.Left:
            {
                targetButton.TitleEdgeInsets     = new UIEdgeInsets(0, 20, 0, 0);
                targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            }
            break;

            case TextAligment.Top:
            {
                targetButton.TitleEdgeInsets   = new UIEdgeInsets(5, 0, 0, 0);
                targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Top;
            }
            break;

            case TextAligment.Right:
            {
                var yCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterY, 1, 0);
                var xLeftCt   = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Left, 1, 0);

                targetButton.AddConstraint(yCenterCt);
                targetButton.AddConstraint(xLeftCt);

                targetButton.TitleEdgeInsets     = new UIEdgeInsets(0, 0, 0, 20);
                targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            }
            break;

            case TextAligment.Bottom:
            {
                var xCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterX, 1, 0);
                var yTopCt    = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Top, 1, 0);

                targetButton.AddConstraint(xCenterCt);
                targetButton.AddConstraint(yTopCt);

                targetButton.TitleEdgeInsets   = new UIEdgeInsets(0, 0, 5, 0);
                targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Bottom;
            }
            break;

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #5
0
        /// <summary>
        /// Configure this instance.
        /// </summary>
        private void configure()
        {
            this.TranslatesAutoresizingMaskIntoConstraints = false;
            this.BackgroundColor     = UIColor.DarkGray;
            this.Layer.CornerRadius  = CornerRadius;
            this.Layer.MasksToBounds = true;

            IconImageView = new UIImageView();
            IconImageView.TranslatesAutoresizingMaskIntoConstraints = false;
            IconImageView.BackgroundColor = UIColor.Clear;
            IconImageView.ContentMode     = IconContentMode;

            this.AddSubview(IconImageView);

            MessageLabel = new UILabel();
            MessageLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            MessageLabel.TextColor       = UIColor.White;
            MessageLabel.Font            = MessageTextFont;
            MessageLabel.BackgroundColor = UIColor.Clear;
            MessageLabel.LineBreakMode   = UILineBreakMode.CharacterWrap;
            MessageLabel.Lines           = 2;
            MessageLabel.TextAlignment   = UITextAlignment.Left;
            MessageLabel.Text            = Message;

            this.AddSubview(MessageLabel);

            ActionButton = new UIButton();
            ActionButton.TranslatesAutoresizingMaskIntoConstraints = false;
            ActionButton.Hidden          = string.IsNullOrEmpty(ActionText);
            ActionButton.BackgroundColor = UIColor.Clear;
            ActionButton.TitleLabel.Font = ActionTextFont;
            ActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            ActionButton.SetTitle(ActionText, UIControlState.Normal);
            ActionButton.SetTitleColor(ActionTextColor, UIControlState.Normal);
            ActionButton.TouchUpInside += (s, e) =>
            {
                if (!ActionButton.Hidden && ActionButton.Title(UIControlState.Normal) != String.Empty && ActionButton != null)
                {
                    ActionBlock(this);
                    dismissAnimated(true);
                }
            };

            this.AddSubview(ActionButton);

            SecondActionButton = new UIButton();
            SecondActionButton.TranslatesAutoresizingMaskIntoConstraints = false;
            SecondActionButton.BackgroundColor = UIColor.Clear;
            SecondActionButton.TitleLabel.Font = SecondActionTextFont;
            SecondActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            SecondActionButton.SetTitle(SecondActionText, UIControlState.Normal);
            SecondActionButton.SetTitleColor(SecondActionTextColor, UIControlState.Normal);
            SecondActionButton.TouchUpInside += (s, e) =>
            {
                if (!SecondActionButton.Hidden && SecondActionButton.Title(UIControlState.Normal) != String.Empty && SecondActionBlock != null)
                {
                    SecondActionBlock(this);
                    dismissAnimated(true);
                }
            };

            this.AddSubview(SecondActionButton);

            SeperateView = new UIView();
            SeperateView.TranslatesAutoresizingMaskIntoConstraints = false;
            SeperateView.BackgroundColor = UIColor.Gray;

            this.AddSubview(SeperateView);

            ActivityIndicatorView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            ActivityIndicatorView.TranslatesAutoresizingMaskIntoConstraints = false;
            ActivityIndicatorView.StopAnimating();

            this.AddSubview(ActivityIndicatorView);

            // Add constraints
            invalidateHorizontalConstraints();

            var vConstraintsForIconImageView = NSLayoutConstraint.FromVisualFormat(
                "V:|-2-[iconImageView]-2-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { IconImageView }, new NSObject[] { new NSString("iconImageView") })
                );

            var vConstraintsForMessageLabel = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[messageLabel]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { MessageLabel }, new NSObject[] { new NSString("messageLabel") })
                );

            var vConstraintsForSeperateView = NSLayoutConstraint.FromVisualFormat(
                "V:|-4-[seperateView]-4-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { SeperateView }, new NSObject[] { new NSString("seperateView") })
                );

            var vConstraintsForActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[actionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { ActionButton }, new NSObject[] { new NSString("actionButton") })
                );

            var vConstraintsForSecondActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[secondActionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { SecondActionButton }, new NSObject[] { new NSString("secondActionButton") })
                );

            iconImageViewWidthConstraint = NSLayoutConstraint.Create(IconImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarIconImageViewWidth);

            actionButtonWidthConstraint = NSLayoutConstraint.Create(ActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            secondActionButtonWidthConstraint = NSLayoutConstraint.Create(SecondActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            var vConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
                "V:|-2-[activityIndicatorView]-2-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { ActivityIndicatorView }, new NSObject[] { new NSString("activityIndicatorView") })
                );

            var hConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
                "H:[activityIndicatorView]-2-|",
                0,
                new NSDictionary(),
                NSDictionary.FromObjectsAndKeys(
                    new NSObject[] { ActivityIndicatorView },
                    new NSObject[] { new NSString("activityIndicatorView") })
                );

            IconImageView.AddConstraint(iconImageViewWidthConstraint);
            ActionButton.AddConstraint(actionButtonWidthConstraint);
            SecondActionButton.AddConstraint(secondActionButtonWidthConstraint);

            this.AddConstraints(hConstraints);
            this.AddConstraints(vConstraintsForIconImageView);
            this.AddConstraints(vConstraintsForMessageLabel);
            this.AddConstraints(vConstraintsForSeperateView);
            this.AddConstraints(vConstraintsForActionButton);
            this.AddConstraints(vConstraintsForSecondActionButton);
            this.AddConstraints(vConstraintsForActivityIndicatorView);
            this.AddConstraints(hConstraintsForActivityIndicatorView);
        }
コード例 #6
0
ファイル: ImageButtonRenderer.cs プロジェクト: NamXH/Orchard
        private void UpdateImage(string imageName, int widthRequest, int heightRequest, UIButton targetButton)
        {
            var assembly = typeof(App).GetTypeInfo().Assembly;
            UIImage image = null;
            if (imageName != null)
            {
                try
                {
                    image = UIImage.FromResource(assembly, imageName);
                }
                catch (Exception)
                {
                    var path = PCLStorage.FileSystem.Current.LocalStorage.Path;
                    var iPath = PCLStorage.PortablePath.Combine(path, imageName);
                    image = UIImage.FromFile(iPath);
                }
            }

            var imageView = new UIImageView();

            var widthCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, widthRequest);
            var heightCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, heightRequest);

            imageView.AddConstraint(widthCt);
            imageView.AddConstraint(heightCt);
            imageView.TranslatesAutoresizingMaskIntoConstraints = false;
            imageView.Image = image;
            imageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            targetButton.AddSubview(imageView);

            switch (ImageButton.Orientation)
            {
                case TextAligment.Left:
                    {
                        targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 20, 0, 0);
                        targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                    }
                    break;
                case TextAligment.Top:
                    {
                        targetButton.TitleEdgeInsets = new UIEdgeInsets(5, 0, 0, 0);
                        targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Top;
                    }
                    break;
                case TextAligment.Right:
                    {
                        var yCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterY, 1, 0);
                        var xLeftCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Left, 1, 0);

                        targetButton.AddConstraint(yCenterCt);
                        targetButton.AddConstraint(xLeftCt);

                        targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, 20);
                        targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
                    }
                    break;
                case TextAligment.Bottom:
                    {
                        var xCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterX, 1, 0);
                        var yTopCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Top, 1, 0);

                        targetButton.AddConstraint(xCenterCt);
                        targetButton.AddConstraint(yTopCt);

                        targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 5, 0);
                        targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Bottom;
                    }
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }