How to set cornerRadius for only top-left and top-right corner of a UIView?

后端 未结 26 3475
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 06:14

Is there a way to set cornerRadius for only top-left and top-right corner of a UIView?

I tried the following, but it end up not seeing the

26条回答
  •  被撕碎了的回忆
    2020-11-22 07:15

    This is how you can set a corner radius for each corner of a button with Xamarin in C#:

    var maskPath = UIBezierPath.FromRoundedRect(MyButton.Bounds, UIRectCorner.BottomLeft | UIRectCorner.BottomRight,
        new CGSize(10.0, 10.0));
    var maskLayer = new CAShapeLayer
    {
        Frame = MyButton.Bounds,
        Path = maskPath.CGPath
    };
    MyButton.Layer.Mask = maskLayer;
    

提交回复
热议问题