c# - 您如何才能在 Xamarin.iOS UITableView 上仅圆化 2 个角?

标签 c# ios uitableview xamarin.ios xamarin

我正在使用当前版本的 Xamarin.iOS 和 C# 开发一个 iPad 应用程序,并试图创建一个只有两个角(右上角和右下角)圆角的 UITableView。我知道如何通过设置 myTable.Layer.CornerRadius = 6f; 使所有角变圆,但不知道如何只对其中两个角进行圆角处理。我环顾四周,但只能看到 Objective-C 的答案。这是我目前拥有的:

    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;
    }

有什么想法可以将其更改为仅圆角中的两个吗?

谢谢,

最佳答案

从 iOS 11 开始,有一个新属性叫做:

例如 3 给了我两个顶角圆

view.Layer.MaskedCorners = (CoreAnimation.CACornerMask)3;
view.Layer.CornerRadius = 15f;
  • 0:没有圆角
  • 1:左上角
  • 2:右上角
  • 3:左上角和右上角(两个上角)
  • 4:左下
  • 5:左上角和左下角(两个左角)
  • 6:右上和左下
  • 7:左上角和右上角,左下角(除右下角外的所有角)
  • 8:右下角
  • 9:左上,右下
  • 10:右上角和右下角(两个右角)
  • 11:两个上角,右下角(除左下角外的所有角)
  • 12:左下角和右下角(两个底角)
  • 13:左下角和右下角,左上角(除右上角外的所有角)
  • 14:左下角和右下角,右上角(除左上角外的所有角)
  • 15:所有角都是圆的

关于c# - 您如何才能在 Xamarin.iOS UITableView 上仅圆化 2 个角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21330595/

相关文章:

c# - 如何覆盖 MongoDB Gridfs 中的文件?

ios - ios开发中的WSDL webservice

ios - 调用 array.removeAll() 后 tableview.reload 不起作用 swift 5

ios - 当 UITableView 加载并在滚动后得到修复时,UILabel 向左移动

c# - 检查 XElement(Record) 是否存在?

c# - Unity - IEnumerator 的 yield 返回 null

c# - 哪个 WPF 元素用于 Visual Studio 代码编辑器?

ios - 每个随机数调用事件

objective-c - 在 iOS 中更改 ViewControllers 和传递数据

ios - TableViewController 中各部分上方的 Xcode 文本字段