示例#1
0
 /// <summary>创建UIButton
 /// </summary>
 /// <param name="btn"></param>
 /// <param name="frame"></param>
 /// <param name="title"></param>
 /// <param name="alignment"></param>
 /// <param name="tag"></param>
 public void CreatButton(UIButton btn, CGRect frame, string title, UIControlContentHorizontalAlignment alignment, int tag)
 {
     btn.Frame = frame;
     btn.Tag   = tag;
     btn.SetTitle(title, UIControlState.Normal);
     btn.SetTitleColor(UIColor.White, UIControlState.Normal);
     btn.HorizontalAlignment = alignment;
     btn.TitleLabel.Font     = UIFont.SystemFontOfSize(14.0f);
     btn.TouchUpInside      += Btn_TouchUpInside;
     View.AddSubview(btn);
 }
示例#2
0
        private void Initialize()
        {
            LabelAlignment = UIControlContentHorizontalAlignment.Left;
            BackgroundColor = UIColor.Clear;

            Label = new UILabel(new RectangleF(26, 5, 80, 32));
            Label.BackgroundColor = UIColor.Clear;
            Label.Text = "Back";
            Label.TextColor = UIColor.FromRGB(182, 213, 233);
            Label.TextAlignment = UITextAlignment.Left;
            Label.Font = UIFont.FromName("HelveticaNeue", 14.0f);

            ImageChevron = new UIImageView(UIImage.FromBundle("Images/Tables/chevron_left_blue"));
            ImageChevron.BackgroundColor = UIColor.Clear;
            ImageChevron.Frame = new RectangleF(0, 0, 22, 44);

            AddSubview(Label);
            AddSubview(ImageChevron);
        }
示例#3
0
        private void Initialize()
        {
            LabelAlignment = UIControlContentHorizontalAlignment.Left;
            BackgroundColor = GlobalTheme.SecondaryColor;
            Layer.CornerRadius = 8;
            TintColor = UIColor.White;
            SetTitleColor(UIColor.White, UIControlState.Normal);

            TitleLabel.BackgroundColor = UIColor.Clear;
            TitleLabel.TextColor = UIColor.White;
            TitleLabel.TextAlignment = UITextAlignment.Left;
            TitleLabel.Font = UIFont.FromName("HelveticaNeue", 14.0f);
            TitleLabel.Frame = Bounds;
            TitleLabel.Text = Title(UIControlState.Normal);

            Image = new UIImageView();
            Image.BackgroundColor = UIColor.Clear;
            Image.Frame = new RectangleF(9, 9, 26, 26);
            AddSubview(Image);

            UpdateLayout();
        }
示例#4
0
        GetAlignment(string alignment)
        {
            UIControlContentHorizontalAlignment al1 = UIControlContentHorizontalAlignment.Center;
            UITextAlignment al2 = UITextAlignment.Center;

            switch (alignment)
            {
            case "left":
                al1 = UIControlContentHorizontalAlignment.Left;
                al2 = UITextAlignment.Left;
                break;

            case "right":
                al1 = UIControlContentHorizontalAlignment.Right;
                al2 = UITextAlignment.Right;
                break;

            case "top":
            case "bottom":     // there is no top & bottom for iOS, only for Android
            case "center":
                al1 = UIControlContentHorizontalAlignment.Center;
                al2 = UITextAlignment.Center;
                break;

            case "fill":
            case "natural":
                al1 = UIControlContentHorizontalAlignment.Fill;
                al2 = UITextAlignment.Natural;
                break;

            case "justified":
                al1 = UIControlContentHorizontalAlignment.Center;
                al2 = UITextAlignment.Justified;
                break;
            }
            return(new Tuple <UIControlContentHorizontalAlignment, UITextAlignment>(al1, al2));
        }
示例#5
0
        private void SetSpannedText(string span, bool force = true)
        {
            if (_view != null && span != null)
            {
                UIControlContentHorizontalAlignment alignment = _view.HorizontalAlignment;
                UIEdgeInsets textInset = _view.ContentEdgeInsets;

                var str   = new NSString(string.Format(span, _text));
                var error = new NSError();

                var title = new NSAttributedString(str.DataUsingEncoding(NSStringEncoding.Unicode)
                                                   , new NSAttributedStringDocumentAttributes {
                    DocumentType = NSDocumentType.HTML
                }
                                                   , ref error);

                if (_view != null && (force || _blinkAllowed))
                {
                    _view.SetAttributedTitle(title, UIControlState.Normal);
                    _view.HorizontalAlignment = alignment;
                    _view.ContentEdgeInsets   = textInset;
                }
            }
        }
 public static TControl WithAlignment <TControl>(this TControl control, UIControlContentHorizontalAlignment horizontalAlignment) where TControl : UIControl
 {
     control.HorizontalAlignment = horizontalAlignment;
     return(control);
 }