我想在我的 MvxTableViewController 的每个 tablevievcell 中绘制一个矩形。我有一个自定义 cellLabel 扩展 UIView
namespace Next.Client.Application.iOS.Views.UI
{
[Register("CellLabel")]
public class CellLabel : UIView
{
public CellLabel()
{
Initialize();
}
public CellLabel(RectangleF bounds)
: base(bounds)
{
Initialize();
}
void Initialize()
{
BackgroundColor = UIColor.Red;
}
public override void Draw(RectangleF rect)
{
base.Draw(rect);
//get graphics context
using (CGContext gc = UIGraphics.GetCurrentContext())
{
//set up drawing attributes
gc.SetLineWidth(1);
UIColor.Blue.SetFill();
UIColor.Red.SetStroke();
//create geometry
var path = new CGPath();
path.AddLines(new PointF[]{
new PointF (0, 45),
new PointF (80, 45),
new PointF (90, 50),
new PointF (0, 50)
});
path.CloseSubpath();
//add geometry to graphics context and draw it
gc.AddPath(path);
gc.DrawPath(CGPathDrawingMode.FillStroke);
}
}
}
}
和一个自定义单元格在哪里绘制
namespace Next.Client.Application.iOS
{
public partial class ObservationCell : MvxTableViewCell
{
public static readonly UINib Nib = UINib.FromName ("ObservationCell", NSBundle.MainBundle);
public static readonly NSString Key = new NSString ("ObservationCell");
private CellLabel _labelView;
public ObservationCell (IntPtr handle) : base (handle)
{
_labelView = new CellLabel();
this.AddSubview(_labelView);
this.DelayBind(() => {
var set = this.CreateBindingSet<ObservationCell, Observation>();
set.Bind(MainLbl).To(observation => observation.BrutText);
set.Bind(SubLeftLbl).To(observation => observation.Praticien.Personne.DisplayFullName);
set.Bind(SubRightLbl).To(observation => observation.DateTimeHumanShort);
set.Apply();
});
}
public static ObservationCell Create ()
{
return (ObservationCell)Nib.Instantiate (null, null) [0];
}
}
}
但什么都没有出现:/有什么想法吗?