简体   繁体   中英

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

这显示了我使用单元格的.Layer属性在代码中创建的红色边框,然后显示了该单元格周围的默认边框,即该边框位于红色边框的内部

IIRC (can't try it right now) this is draw with the background view. So you'll need to either remove it, like:

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

or sets the Bounds properties to Empty , like:

cell.BackgroundView.Bounds = RectangleF.Empty;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM