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

45 lines
938 B
C#

using System;
using UIKit;
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);
}
}
}