I want to draw a 'down' triangle over a button (like a windows dropdown list). In Android, putting code into the Draw method draws after the button is rendered by the system. In iOS it draws before, so unless I make the button transparent you don't see the triangle.
Any ideas?
Android Code:
public override void Draw( Canvas canvas ) {
base.Draw( canvas );
var paint = new Paint();
paint.Color = Element.TextColor.ToAndroid();
var rect = new Rect();
GetDrawingRect( rect );
var path = new Path();
int bottom = rect.Top + rect.Height() * 3 / 4;
int top = bottom - rect.Height() * 2 / 5;
int right = rect.Right - rect.Height() / 4;
int left = right - rect.Height() / 2;
path.MoveTo( left, top );
path.LineTo( right, top );
path.LineTo( (left + right) / 2, bottom );
canvas.DrawPath( path, paint );
}
iOS Code:
public override void Draw( CGRect rect ) {
base.Draw( rect );
using ( var context = UIGraphics.GetCurrentContext() ) {
context.BeginPath();
var bottom = rect.Top + rect.Height * 3 / 4;
var top = bottom - rect.Height * 2 / 5;
var right = rect.Right - rect.Height / 4;
var left = right - rect.Height / 2;
context.MoveTo( left, top );
context.AddLineToPoint( right, top );
context.AddLineToPoint( (left + right) / 2, bottom );
context.SetFillColor( App.Colors.Black.ToCGColor() );
context.ClosePath();
context.FillPath();
}
}