我正在尝试更改占位符的字体,但是尽管出现了占位符文本,但字体是标准字体。我使用以下方法设置我的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];
答案 0 :(得分:2)
NSFontAttributeName
键的值应为UIFont
对象:
name.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Name" attributes: @{
NSFontAttributeName: [UIFont fontWithName:@"Champagne&Limousines" size:12]
}];