1

I am trying to change the font of my placeholder but although the placeholder text appears, the font is the standard. Im using the following method to set up my UITextField:

    UITextField *name = [[UITextField alloc] initWithFrame:CGRectMake(25, 0, frame.size.width - 50, 50)];
    name.borderStyle = UITextBorderStyleNone;
    name.background = [UIImage imageNamed:@"UITextField_orange.png"];
    name.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Name" attributes:@{NSFontAttributeName:@"Champagne&Limousines"}];;
    [self addSubview:name];
Dhwanit Zaveri
  • 465
  • 1
  • 5
  • 15
  • 1
    See [this question][1] [1]: http://stackoverflow.com/questions/15031678/uitextfield-attributedplaceholder-has-no-effect Seems like you ask same question – Ievgenii Dec 24 '13 at 14:05

1 Answers1

2

The value that goes with the NSFontAttributeName key should be a UIFont object:

name.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Name" attributes: @{
  NSFontAttributeName: [UIFont fontWithName:@"Champagne&Limousines" size:12]
}];
pr1001
  • 21,727
  • 17
  • 79
  • 125