Exemplo n.º 1
0
        private void SetupNotificationView()
        {
            if (NotificationNumber > 0)
            {
                _numberView.Frame  = new CGRect(0, 0, 38, 28f);
                _numberView.Center = new CGPoint(ContentView.Bounds.Width - 44, ContentView.Bounds.Height / 2f);
                _numberView.Text   = NotificationNumber.ToString();

                if (_numberView.Superview == null)
                {
                    AddSubview(_numberView);
                }
            }
            else
            {
                _numberView.RemoveFromSuperview();
            }
        }
Exemplo n.º 2
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            if (ImageView != null)
            {
                var center = ImageView.Center;
                ImageView.Frame  = new CGRect(0, 0, ImageSize, ImageSize);
                ImageView.Center = new CGPoint(ImageSize, center.Y);

                if (RoundedImage)
                {
                    ImageView.Layer.MasksToBounds = true;
                    ImageView.Layer.CornerRadius  = ImageSize / 2f;
                }
                else
                {
                    ImageView.Layer.MasksToBounds = false;
                    ImageView.Layer.CornerRadius  = 0;
                }

                if (TextLabel != null)
                {
                    var frame = TextLabel.Frame;
                    frame.X         = ImageSize * 2;
                    frame.Width    += (TextLabel.Frame.X - frame.X);
                    TextLabel.Frame = frame;
                }
            }

            if (NotificationNumber > 0)
            {
                _numberView.Frame  = new CGRect(0, 0, 38, 28f);
                _numberView.Center = new CGPoint(ContentView.Bounds.Width - 44, ContentView.Bounds.Height / 2f);
                _numberView.Text   = NotificationNumber.ToString();
                AddSubview(_numberView);
            }
            else
            {
                _numberView.RemoveFromSuperview();
            }

            SeparatorInset = new UIEdgeInsets(0, TextLabel.Frame.Left, 0, 0);
        }