在Xamarin.iOS中实现TextLayer的垂直对齐
代码如下: public class SHLCTextLayer : CATextLayer { public SHLCTextLayer(IntPtr handle) : base(handle) { } public SHLCTextLayer() : base() { } public SHLCTextLayer(NSCoder coder) : base(coder) { } public SHLCTextLayer(NSObjectFlag t) : base(t) { } public override void DrawInContext(CGContext ctx) { try { var height = this.Bounds.Size.Height; var fontSize = this.FontSize; var yDiff = (height - fontSize) / 2 - fontSize / 10; ctx.SaveState(); ctx.TranslateCTM((nfloat)0.0f, yDiff); base.DrawInContext(ctx); ctx.RestoreState(); } catch (Exception e) { ErrorReporter.Report(e); } } }……