UITextField's -attributedPlaceholder method behaves differently from documented
| Originator: | GeoffPado | ||
| Number: | rdar://15698327 | Date Originated: | 12-19-2013 |
| Status: | Open | Resolved: | |
| Product: | Documentation | Product Version: | |
| Classification: | Other Bug | Reproducible: | N/A |
Summary:
The documentation for UITextField's -attributedPlaceholder method states: "If set, the placeholder string is drawn using a 70% grey color and the remaining style information (except the text color) of the attributed string." At least as of iOS 7, this differs from actual behavior in two ways:
1. It is in fact possible to change the text color of the string by using -attributedPlaceholder and NSForegroundColorAttributeName.
2. Changing the attributed string's font using NSFontAttributeName does not have any effect.
Steps to Reproduce:
1. Create a UITextField.
2. Call that text field's -attributedPlaceholder method:
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"lorem ipsum" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-ThinItalic" size:24.0f], NSForegroundColorAttributeName: [UIColor redColor]}];
Expected Results:
The text field displays the text in a 70% grey color, with the text set in the font specified by NSFontAttributeName.
Actual Results:
The text field displays the text in the color specified by NSForegroundColorAttributeName, with the text set in whatever -font returns.
Version:
UITextField Class Reference: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/Reference/UITextField.html#//apple_ref/doc/uid/TP40006888-CH3-SW56
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!