コード例 #1
0
ファイル: ContentRows.cs プロジェクト: jivkopetiov/StackApp
            public SpotNewsCell(string reuseIdentifier)
                : base(UITableViewCellStyle.Default, reuseIdentifier)
            {
                _text = new UILabel();
                _text.BackgroundColor = UIColor.Clear;
                _text.Lines = 0;
                Add (_text);

                _details = new UILabel();
                _details.BackgroundColor = UIColor.Clear;
                _details.TextColor = UIColor.Gray;
                _details.Lines = 0;
                Add (_details);

                _byline = new UILabel();
                _byline.Font = UIFont.ItalicSystemFontOfSize(12);
                _byline.BackgroundColor = UIColor.Clear;
                _byline.TextColor = UIColor.Gray;
                Add (_byline);

                _image = new UIImageView();
                _image.ContentMode = UIViewContentMode.ScaleAspectFit;
                Add (_image);

                _badge = new TDBadgeView(RectangleF.Empty);
                _badge.Parent = this;
                Add (_badge);
            }
コード例 #2
0
ファイル: ContentRows.cs プロジェクト: jivkopetiov/StackApp
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            if (Settings.BadgeNumber2 != null && Badge2 == null) {
                Badge2 = new TDBadgeView(RectangleF.Empty);
                Badge2.Parent = this;

                ContentView.AddSubview(Badge2);
            }

            LayoutSubviewsImpl(Settings.BadgeNumber, Badge, Settings.BadgeColor, Settings.BadgeColorHighlighted);
            if (Settings.BadgeNumber2 != null && Badge2 != null)
                LayoutSubviewsImpl(Settings.BadgeNumber2, Badge2, Settings.BadgeColor2, Settings.BadgeColorHighlighted2, isSecondBadge:true);
        }
コード例 #3
0
ファイル: ContentRows.cs プロジェクト: jivkopetiov/StackApp
        private void LayoutSubviewsImpl(string badgeNum, TDBadgeView badge, UIColor badgeColor, UIColor badgeColorHighlighted, bool isSecondBadge = false)
        {
            if (!string.IsNullOrEmpty(badgeNum))
            {
                //force badges to hide on edit.
                if (Editing)
                    badge.Hidden = true;
                else
                    badge.Hidden = false;

                var ns = new NSString(badgeNum);
                SizeF badgeSize = ns.StringSize(UIFont.BoldSystemFontOfSize(14));

                RectangleF badgeFrame;

                float additionalOffset = 0;
                if (isSecondBadge) {
                    float firstBadgeWidth = new NSString(Settings.BadgeNumber).StringSize (UIFont.BoldSystemFontOfSize(14)).Width;
                    additionalOffset = firstBadgeWidth + 16 + 4;
                }

                badgeFrame = new RectangleF(ContentView.Frame.Size.Width - (badgeSize.Width+16) - 10 - additionalOffset
                                            , Convert.ToSingle(Math.Round((ContentView.Frame.Size.Height - 18) /2))
                                            , badgeSize.Width + 16f
                                            , 18f);

                badge.Frame = badgeFrame;
                badge.BadgeNumber = badgeNum;
                badge.Parent = this;

                if (TextLabel.Frame.X + TextLabel.Frame.Size.Width >= badgeFrame.X)
                {
                    float badgeWidth = Convert.ToSingle(TextLabel.Frame.Size.Width - badgeFrame.Size.Width - 10.0);

                    TextLabel.Frame = new RectangleF(TextLabel.Frame.X
                                                          , TextLabel.Frame.Y
                                                          , badgeWidth
                                                          , TextLabel.Frame.Size.Height);
                }

                if ((DetailTextLabel.Frame.X + DetailTextLabel.Frame.Size.Width) >= badgeFrame.X)
                {
                    float badgeWidth = Convert.ToSingle(DetailTextLabel.Frame.Size.Width - badgeFrame.Size.Width - 10);
                    DetailTextLabel.Frame = new RectangleF(DetailTextLabel.Frame.X
                                                           , DetailTextLabel.Frame.Y
                                                           , badgeWidth
                                                           , DetailTextLabel.Frame.Size.Height);
                }

                //set badge hightlighed colours or use defaults
                if (badgeColorHighlighted != null)
                    badge.BadgeColorHighlighted = badgeColorHighlighted;
                else
                    badge.BadgeColorHighlighted = UIColor.FromRGBA(1.0f, 1.0f, 1.0f, 1.000f);

                if (badgeColor != null)
                    badge.BadgeColor = badgeColor;
                else
                    badge.BadgeColor = UIColor.FromRGBA(0.530f, 0.600f, 0.738f, 1.000f);
            }
            else
            {
                badge.Hidden = true;
            }
        }
コード例 #4
0
ファイル: ContentRows.cs プロジェクト: jivkopetiov/StackApp
        public TDBadgedCell(UITableViewCellStyle style, string reuseIdentifier)
            : base(style, reuseIdentifier)
        {
            Badge = new TDBadgeView(RectangleF.Empty);
            Badge.Parent = this;

            this.ContentView.AddSubview(this.Badge);
        }