Changing UITextField Placeholder Font and Color

There are no settings available in a UITextField to make the placeholder font different (color, smaller, fontface etc) from the font or textColor. You would think that it would be possible with UITextField attributedPlaceholder, but you would be wrong. The way to get around this is to sublclass UITextField and override drawPlaceholderInRect. Occasionally, this will cause placeholder text to be pinned to the top of the UITextField, which can be fixed by vertically centering the draw rect.

- (void) drawPlaceholderInRect:(CGRect)rect {
    if (self.useSmallPlaceholder) {
        NSDictionary *attributes = @{
                                     NSForegroundColorAttributeName : kInputPlaceholderTextColor,
                                     NSFontAttributeName : [UIFont fontWithName:kInputPlaceholderFontName size:kInputPlaceholderFontSize]
                                     };

    //center vertically
    CGSize textSize = [self.placeholder sizeWithAttributes:attributes];
    CGFloat hdif = rect.size.height - textSize.height;
    hdif = MAX(0, hdif);
    rect.origin.y += ceil(hdif/2.0);

    [[self placeholder] drawInRect:rect withAttributes:attributes];
}
else {
    [super drawPlaceholderInRect:rect];
}

}