2

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

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

4

1 回答 1

1

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;
于 2013-03-30T23:05:10.520 回答