具有与 iOS 8 SDK 相同的 API(不支持文本字段),兼容 iOS 7。
它与 iOS 8 SDK 具有完全相同的 API(除了文本字段部分)。此外,使用 -show
、-dismiss
方法可以在您想要的地方弹出警报,无需担心如何获取当前视图控制器的指针。
示例
PRAlertController *alertController = [PRAlertController alertControllerWithTitle:@"Title"
message:@"This is the message."
preferredStyle:PRAlertControllerStyleAlert];
PRAlertAction *firstAction = [PRAlertAction actionWithTitle:@"First"
style:PRAlertActionStyleDefault
handler:^(PRAlertAction *action) {
[self doFirstAction];
}];
PRAlertAction *secondAction = [PRAlertAction actionWithTitle:@"Second"
style:PRAlertActionStyleDefault
handler:^(PRAlertAction *action) {
[self doSecondAction];
}];
PRAlertAction *destructiveAction = [PRAlertAction actionWithTitle:@"Destructive"
style:PRAlertActionStyleDestructive
handler:^(PRAlertAction *action) {
[self doDestructiveAction];
}];
PRAlertAction *cancelAction = [PRAlertAction actionWithTitle:@"Cancel"
style:PRAlertActionStyleCancel
handler:^(PRAlertAction *action) {
[self doCancelAction];
}];
[alertController addAction:firstAction];
[alertController addAction:secondAction];
[alertController addAction:destructiveAction];
[alertController addAction:cancelAction];
[alertController show];
看起来很简单。
此代码根据 MIT 许可协议 的条款和条件进行分发。
您可以通过以下方式支持我
:-)