[英]Figuring out how to get rid of border around cell in UITableView cell
I recently had help getting to the properties available on a cell by overriding the GetCell method using monotouch.dialog. 最近,我通过使用monotouch.dialog覆盖了GetCell方法来帮助获取单元格上的可用属性。 My problem now is that I can't see to get rid of the default border around cells. 我现在的问题是我看不到摆脱单元格周围的默认边框。
I was able to figure out how to draw my own border around the cell (I believe it is using core graphics and the .Layer property on a cell for this). 我能够弄清楚如何在单元格周围绘制自己的边框(我相信它为此使用了核心图形和单元格上的.Layer属性)。 However, the old border still remains, and I can't find a property to disable this. 但是,旧边框仍然保留,我找不到属性来禁用此功能。
Ideally I would prefer to just be able to customise the existing border myself, but if this is not possible (without needing to make my own cell graphics), then I would like to remove the default border and use the border generated in code. 理想情况下,我希望自己能够自定义现有边框,但是,如果不可能(不需要制作自己的单元格图形),那么我想删除默认边框并使用代码中生成的边框。
See below for the override method and a screenshot of what I have so far: 请参阅下面的重写方法和到目前为止的屏幕截图:
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;
}
IIRC (can't try it right now) this is draw with the background view. IIRC(目前无法尝试),这是使用背景视图绘制的。 So you'll need to either remove it, like: 因此,您需要将其删除,例如:
cell.BackgroundView = new UIView (RectangleF.Empty);
or sets the Bounds
properties to Empty
, like: 或将Bounds
属性设置为Empty
,例如:
cell.BackgroundView.Bounds = RectangleF.Empty;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.