Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:00:25+00:00 2026-06-12T08:00:25+00:00

I am trying to set the placeholder text for a UITextField to a different

  • 0

I am trying to set the placeholder text for a UITextField to a different color. I have learned that I need to subclass and override 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 have so far, but I just can’t figure out how to get it just right. I am 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();
            //Not sure what to put here
            base.DrawPlaceholder (rect);}
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:00:26+00:00Added an answer on June 12, 2026 at 8:00 am

    The original ObjC code does not call super (it’s base method) but drawInRect:. Have you tried the same with MonoTouch ? e.g.

    public override void DrawPlaceholder (RectangleF rect)
    {
        using (UIFont font = UIFont.SystemFontOfSize (16))
        using (UIColor col = new UIColor (0,0,255.0,0.7)) {
            col.SetFill ();
            base.DrawString (rect, font);
        }
    }
    

    Note: drawInRect:WithFont: maps to the DrawString extension method in C# (which can be called on any string).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a UITextField with default text and set to clear when editing
I'm trying to set up a system where GUI objects that derive from a
I subclassed EntryElement and have set the UILineBreakMode in the GetCell method as such:
I have an 'inlineformset_factory', and I'm trying figure out how to set attributes for
I'm trying to set a default text value for the already derived column Sub1
I've been trying to set up a triangle class that contains three Vector3's and
I have a dynamic number of data elements that need to be added to
html5 supports the placeholder attribute on input[type=text] elements, but I need to handle non-compliant
I have a set of radio buttons that work when clicked where it will
I have a field in my model, :birth_time, that I'm trying to build from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.