Reputation: 475
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
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