I was wondering that today, but then I stumpled upon this answer on StackOverflow, which I converted into this little golden C# nugget of overridden awesomeness:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
public class UILabelExtended : UILabel { UIEdgeInsets insets = UIEdgeInsets.Zero; public UILabelExtended (RectangleF frame) : base (frame) { } public override void DrawText (RectangleF rect) { base.DrawText (Insets.InsetRect (rect)); } public UIEdgeInsets Insets { get { return insets; } set { insets = value; SetNeedsDisplay (); } } } |
Not much, I know 😉 but I like to make a calm start when I suddenly start blogging about new subjects. More iOS and Xamarin will follow…
Btw. I really love how everything in the Cocoa Touch framework lends itself so well to be customized and tweaked by overriding methods.