我正在尝试在我的Xamarin.iOS应用程序中创建一个带填充的UILabel.本机Objective-C应用程序中最流行的解决方案是覆盖drawTextInRect:
- (void)drawTextInRect:(CGRect)rect { UIEdgeInsets insets = {0,5,5}; return [super drawTextInRect:UIEdgeInsetsInsetRect(rect,insets)]; }
这看起来很简单,我无法弄清楚如何将其转换为C#.这是我最好的尝试:
internal class PaddedLabel : UILabel { public UIEdgeInsets Insets { get; set; } public override void DrawText(RectangleF rect) { var padded = new RectangleF(rect.X + Insets.Left,rect.Y,rext.Width + Insets.Left + Insets.Right,rect.Height); base.DrawText(padded); } }
我认为主要问题是我找不到Xamarin等效的UIEdgeInsetsInsetRect.
有什么建议?