您的位置:首页 > 产品设计 > UI/UE

iOS UIAlertController使用方法如何使用

2016-05-18 17:15 633 查看
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"密码"
message:nil
preferredStyle:UIAlertControllerStyleAlert];

[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {

//
可以在这里对textfield进行定制,例如改变背景色

textField.placeholder =
@"请输入私人直播室的密码";

}];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) {

NSLog(@"The \"Okay/Cancel\" alert's cancel action occured.");

}];

UIAlertAction *otherAction = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {

NSLog(@"The \"Okay/Cancel\" alert's other action occured.");

}];

// Add the actions.

[alertController addAction:cancelAction];

[alertController addAction:otherAction];

[self
presentViewController:alertController animated:YES
completion:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: