UIAlertController

集成了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];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章