skiasharp/samples/Basic/iOS/SkiaSharpSample/ViewController.cs

43 lines
904 B
C#
Raw Normal View History

using SkiaSharp;
2017-12-20 05:31:29 +02:00
using SkiaSharp.Views.iOS;
namespace SkiaSharpSample;
public partial class ViewController : UIViewController
2017-12-20 05:31:29 +02:00
{
protected ViewController(IntPtr handle)
: base(handle)
2017-12-20 05:31:29 +02:00
{
}
2017-12-20 05:31:29 +02:00
public override void ViewDidLoad()
{
base.ViewDidLoad();
2017-12-20 05:31:29 +02:00
skiaView.IgnorePixelScaling = true;
skiaView.PaintSurface += OnPaintSurface;
}
2017-12-20 05:31:29 +02:00
private void OnPaintSurface(object? sender, SKPaintSurfaceEventArgs e)
{
// the the canvas and properties
var canvas = e.Surface.Canvas;
2017-12-20 05:31:29 +02:00
// make sure the canvas is blank
canvas.Clear(SKColors.White);
2017-12-20 05:31:29 +02:00
// draw some text
using var paint = new SKPaint
{
Color = SKColors.Black,
IsAntialias = true,
Style = SKPaintStyle.Fill
};
using var font = new SKFont
{
Size = 24
};
var coord = new SKPoint(e.Info.Width / 2, (e.Info.Height + font.Size) / 2);
canvas.DrawText("SkiaSharp", coord, SKTextAlign.Center, font, paint);
2017-12-20 05:31:29 +02:00
}
}