【发布时间】:2014-03-17 07:42:12
【问题描述】:
有谁知道如何在 UIAlertView 中更改 UITextField 的字体大小?以下是我的代码...
- (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];
}
【问题讨论】:
-
您好,我只是在这里说我对您的问题投了赞成票,因为用户在没有给出任何解释的情况下对它投了反对票。只有在有解释的情况下才允许投反对票。
-
您使用的是默认 UIAlertView,而不是自定义。我认为你不能这样做。
-
在ios7之前可以做,之后就不行了。但是,您可以创建自己的自定义视图,类似于 UIAlertView 并进行任何您需要的更改。
标签: ios iphone uitextfield uialertview