如何使用 Skia Sharp 添加矩形并将填充颜色和描边颜色应用于该对象?

How to add rect using Skia Sharp and apply both fill color and stroke color to that object?

如何使用 Skia Sharp 添加矩形或任何形状并将填充颜色和描边颜色应用到 iOS

中的对象

要同时绘制填充和描边,您必须执行两次绘制操作:

// the rectangle
var rect = SKRect.Create(10, 10, 100, 100);

// the brush (fill with blue)
var paint = new SKPaint {
    Style = SKPaintStyle.Fill,
    Color = SKColors.Blue
};

// draw fill
canvas.DrawRect(rect, paint);

// change the brush (stroke with red)
paint.Style = SKPaintStyle.Stroke;
paint.Color = SKColors.Red;

// draw stroke
canvas.DrawRect(rect, paint);