0

I have created a reverse progress bar in iOS (which starts from the right) using the SO question here. That's the only difference between that other SO question and mine. However, I don't see the label "Hello" which I added as a subview.

    void Setup()
    {
        BackgroundColor = UIColor.Clear;

        Layer.CornerRadius = 30;
        Layer.BackgroundColor = Color.LightGreen.ToCGColor();

        progressLayer = new CAShapeLayer()
        {
            FillColor = Color.FromHex("#1A4694").ToCGColor(),
            Frame = Bounds
        };

        Layer.AddSublayer(progressLayer);

        label = new UILabel(Bounds)
        {
            TextAlignment = UITextAlignment.Center,
            TextColor = UIColor.White,
            BackgroundColor = UIColor.Clear,
            Font = UIFont.FromName("ChalkboardSE-Bold", 20),
            Text = "Hello"
        };
        InsertSubview(label, 100);
    }

    double complete;
    public double Complete
    {
        get { return complete; }
        set { complete = value; SetNeedsDisplay(); }
    }

    public override void Draw(CGRect rect)
    {
        base.Draw(rect);
        var progressWidth = (rect.Width - (Layer.BorderWidth * 2)) * (1 - complete);
        var progressRect = new CGRect(rect.X + progressWidth, rect.Y + Layer.BorderWidth, rect.Width - progressWidth, (rect.Height - Layer.BorderWidth * 2));
        progressLayer.Path = UIBezierPath.FromRoundedRect(progressRect, (UIRectCorner.TopRight | UIRectCorner.BottomRight), new CGSize(30, 30)).CGPath;

    }
}

enter image description here

Katana
  • 401
  • 3
  • 22

0 Answers0