要运行示例项目,克隆仓库,然后首先从 Example 目录运行 pod install
。
为弹窗中的按钮创建动作
IYAlertViewAction *alertActionDefault = [IYAlertViewAction alertActionWithType:kAlertTypeDefault
title:@"Button title"
andHandler:^(id alert) {
//Do something after a button was pressed
}];
显示默认动作的弹窗 - 标题为 "OK" 的按钮。
[IYAlertView presentAlertWithTitle:@"Title"
message:@"Message"
andActions:nil
inViewContext:self.view];
创建带有两个或更多按钮的弹窗
IYAlertViewAction *alertActionDefault = [IYAlertViewAction alertActionWithType:kAlertTypeDefault
title:@"Button title"
andHandler:^(id alert) {
//Do something after a button was pressed
}];
IYAlertViewAction *alertActionDestructive = [IYAlertViewAction alertActionWithType:kAlertTypeDestructive
title:@"Cancel"
andHandler:^(id alert) {
//Do something after a button was pressed
}];
[IYAlertView presentAlertWithTitle:@"Title"
message:@"Message"
andActions:@[alertActionDefault, alertActionDestructive]
inViewContext:self.view];
ivan yorgov, [email protected]
IYAlertView 适用于 MIT 许可。有关更多信息,请参阅 LICENSE 文件。