I am trying to set the placeholder text for a UITextField to a different color. I found out that I need to subclass and override the drawPlaceholderInRect method.
iPhone UITextField - Change placeholder text color
(void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]]; }
Here is what I still have, but I just can't figure out how to do it right. I got confused on the last line, as I donβt know how to map this to MonoTouch / C # objects.
using System; using MonoTouch.UIKit; using MonoTouch.Foundation; using System.Drawing; namespace MyApp { [Register("CustomUITextField")] public class CustomUITextField:UITextField { public CustomUITextField () :base() { } public CustomUITextField (IntPtr handle) :base(handle) { } public override void DrawPlaceholder (RectangleF rect) { UIColor col = new UIColor(0,0,255.0,0.7); col.SetFill();
source share