Dhwanit Zaveri
Dhwanit Zaveri

Reputation: 475

attributedPlaceholder font change

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];

Upvotes: 1

Views: 1672

Answers (1)

pr1001
pr1001

Reputation: 21962

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]
}];

Upvotes: 1

Related Questions