RSActionSheet 是一个简单、基于块的 UIActionSheet 包装器。
RSActionSheet* sheet = [[RSActionSheet alloc] initWithTitle:@"Example"];
[sheet addDestructiveButtonWithTitle:@"Delete Document" handler:^{
[self deleteDocument];
}];
[sheet addButtonWithTitle:@"Do Thing 1" handler:^{
NSLog(@"Do Thing 1 button pressed");
}];
[sheet addCancelButtonWithTitle:@"Cancel" handler:^{
NSLog(@"Cancel button pressed");
}];
[sheet showInView:self.view];
默认情况下,当按钮被点击时,调用按钮处理程序。但是,可以通过设置以下属性来更改这种行为:
typedef NS_ENUM(NSUInteger, RSActionSheetButtonHandlerType) {
RSActionSheetButtonHandlerTypeTapped,
RSActionSheetButtonHandlerTypeWillDismiss,
RSActionSheetButtonHandlerTypeDidDismiss
};
// Default is RSActionSheetButtonHandlerTypeTapped
@property (assign, nonatomic) RSActionSheetButtonHandlerType buttonHandlerType
最后,按钮按其添加的顺序显示 -- 首先添加的按钮是表格中的顶部按钮。
RSActionSheet 根据 MIT 许可证提供。有关更多信息,请参阅 LICENSE 文件。