我需要添加一些标签UIAlertController
和研究后证明,没有正常的方法来做到这一点。但由于可以添加UITextField
,我决定将UITextField
的外观更改为UILabel
(没有边框和背景颜色)。但改变其背景颜色清晰和边框样式没有帮助。我怎样才能做到这一点?
下面是代码:UIAlertController或UITextField UILabel UILabel
- (void)test
{
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"Test Title"
message:@"Test Message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//Do Some action here
}];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:ok];
[alert addAction:cancel];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.text = @"Text: ";
textField.backgroundColor = [UIColor blueColor];
textField.borderStyle = UITextBorderStyleNone;
textField.backgroundColor = [UIColor clearColor];
[textField setUserInteractionEnabled:NO];
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
}];
[self presentViewController:alert animated:YES completion:nil];
}
不中UIAlert消息像一个标签。你基本上想在UIAlert中使用一个自定义标签,以便你可以自定义它的属性(改变字体,颜色等)?请让我知道 – KrishnaCA
@Chaitanya我已更新我的问题。在那里你可以看到我想要做的事情。 –