How can you combine only 2 of the corners on a Xamarin.iOS UITableView?

I am developing an application for iPad using the current version of Xamarin.iOS with C #, and am trying to create UITableViewone that has only two of its corners (top right and bottom right). I know how all corners are rounded by setting myTable.Layer.CornerRadius = 6f;, but I don’t know how to get around only two rounds. I looked around, but can only see responses to Objective-C. This is what I have:

    private UIView GetModalRowHeaderView2(RectangleF bounds)
    {
        UIView view = new UIView(bounds);
        view.BackgroundColor = UIColor.Gray;

        string[] tableItems = new string[] {"Item One","Item Two","Item Three"};

        UITableView myTable = new UITableView(new RectangleF(0, 20, bounds.Width, bounds.Height - 40), UITableViewStyle.Plain);
        myTable.SeparatorInset = UIEdgeInsets.Zero;
        myTable.ScrollEnabled = false;
        myTable.Source = new TableSource(tableItems);

        // Rounds all corners
        myTable.Layer.CornerRadius = 6f;

        view.Add(myTable);

        return view;
    }

Any ideas how I can change this to just two rounds?

Thanks,

+4
source share
1 answer

. Github Xamarin.iOS . .

:

UIBezierPath maskPath = UIBezierPath.FromRoundedRect (this.Bounds, this.eRoundedCorners, new SizeF (this.fCornerRadius, this.fCornerRadius));

CAShapeLayer maskLayer = new CAShapeLayer ();
maskLayer.Frame = this.Bounds;
maskLayer.Path = maskPath.CGPath;

// Set the newly created shape layer as the mask for the image view layer
this.Layer.Mask = maskLayer;
+5

Source: https://habr.com/ru/post/1523501/


All Articles