skiasharp/samples/Basic/iOS/SkiaSharpSample/ViewController.cs
Matthew Leibowitz bc5020b9ee
Modernize the repository and prepare SkiaSharp 3.0 (#2505)
* Merge and modernize the binding projects
* Remove UWP and watchOS
* Add the native assets projects
* Rename bootstrapper.ps1 to build.ps1
* Add new device tests
* Rework the test skipping feature

---------

Co-authored-by: Jerome Laban <jerome.laban@nventive.com>
2023-07-30 23:49:57 +08:00

41 lines
878 B
C#

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