我正在使用当前版本的 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/