Does anyone know how to change the font size of a UITextField within a UIAlertView? The following is my code...
- (void) editTitle
{
NSString *string = kLocalizedString(@"Edit Title");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:string
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField *textField = [alert textFieldAtIndex:0];
if (!self.title) {
textField.text = nil;
}
else {
textField.text = self.title;
}
textField.clearsOnBeginEditing = NO;
textField.clearButtonMode = UITextFieldViewModeAlways;
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
textField.clearsContextBeforeDrawing = NO;
// These statements have no effect on the size of the text field's font
textField.font = [UIFont systemFontOfSize:16.0];
NSDictionary *attributes = @{
NSFontAttributeName: [UIFont systemFontOfSize:16.0]};
textField.typingAttributes = attributes;
[alert show];
}
After iOS 7.x you cannot customize the appearance of alert views,
Why?
Because its view hierarchy is private.It is mentioned clearly in UIAlertView Class Reference:
So unfortunately it is impossible to change the textField font, buttons text color .. etc.
The only solution is using one of the custom UIAlertView's.