OGeek|极客世界-中国程序员成长平台

标题: c# - 弄清楚如何摆脱 UITableView 单元格中单元格周围的边框 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:00
标题: c# - 弄清楚如何摆脱 UITableView 单元格中单元格周围的边框

我最近通过使用 monotouch.dialog 覆盖 GetCell 方法来获取单元格上可用的属性。我现在的问题是我看不到摆脱单元格周围的默认边框。

我能够弄清楚如何在单元格周围绘制自己的边框(我相信它为此使用了核心图形和单元格上的 .Layer 属性)。但是,旧边框仍然存在,我找不到禁用此功能的属性。

理想情况下,我希望自己能够自定义现有边框,但如果这不可能(无需制作我自己的单元格图形),那么我想删除默认边框并使用生成的边框代码。

请参阅下面的覆盖方法和我到目前为止的屏幕截图:

public override UITableViewCell GetCell(UITableView tableView) {
    var cell = base.GetCell(tableView);
    cell.BackgroundColor = Resources.XDarkGrayColor;
    cell.TextLabel.TextColor = Resources.XWhiteColor;
    cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
    cell.Layer.ShadowColor = UIColor.Red.CGColor;
    cell.Layer.BorderColor = UIColor.Red.CGColor;
    cell.Layer.BorderWidth = 2.0f;
    cell.Layer.CornerRadius = 5.0f;
    cell.Layer.ShadowRadius = 2.0f;
    cell.Layer.ShadowOpacity = 0.75f;

    return cell;
}

This shows the red border I created in code using the .Layer property of a cell, and then the default border around the cell just on the inside of the red border



Best Answer-推荐答案


IIRC(现在不能尝试)这是使用背景 View 绘制的。因此,您需要删除它,例如:

cell.BackgroundView = new UIView (RectangleF.Empty);

或将 Bounds 属性设置为 Empty,如:

cell.BackgroundView.Bounds = RectangleF.Empty;

关于c# - 弄清楚如何摆脱 UITableView 单元格中单元格周围的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15724401/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4