集成了UIAlertView和UIActionSheet的功能
通過選擇風格, 可以選擇上述兩種樣式
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"版本信息" message:nil preferredStyle:UIAlertControllerStyleAlert];
這裏選擇彈出框樣式, 可以製成登陸框樣式
alertController.addTextFieldWithConfigurationHandler {
(textField: UITextField!) -> Void in
textField.placeholder = "登錄"
}
alertController.addTextFieldWithConfigurationHandler {
(textField: UITextField!) -> Void in
textField.placeholder = "密碼"
textField.secureTextEntry = true
}
添加按鈕
// UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:nil];
// [alertController addAction:cancleAction];
[alertController addAction:okAction];
//
[self presentViewController:alertController animated:YES completion:nil];