这是一个自定义的actionsheet,显示在UIWindow顶部。无需担心显示/关闭动画的详细部分,它会在内部处理所有这一切。
要运行示例项目,请克隆仓库,然后首先从Examples目录运行pod install
。
要在您的应用程序中使用显示actionsheet,请按照以下步骤操作。
`#import "MKSActionSheetController.h"`
如果您想显示有一个标题
和两个按钮
以及取消按钮
的actionsheet,则您的代码应该如下所示。
`MKSActionSheetController* actionsheetController = [[MKSActionSheetController alloc] init];
[actionsheetController showActionsheetInController:self
title:@"Actionsheet title" //Actionsheet header title text
backgroundColor:[UIColor lightGrayColor] //Actionsheet background color
cancelButtonTitle:@"CancelButton title" //Cancel button title text
button1Title:@"Button1 title" //Button1 title text
button2Title:@"Button1 title" //Button2 title text
cancelButtonColor:[UIColor lightGrayColor]//Cancel button title text color
button1Color:[UIColor darkGrayColor] //Button1 title text color
button2Color:[UIColor darkGrayColor] //Button2 button title text color
completionBlock:^(kActionsheetTappedButtonIndex index) {
//Dissmiss Actionsheet controller
[actionsheetController dismissActionsheet];
//Do appropriate action
}];`
如果您想显示只有一个包含取消按钮
的单个按钮
的actionsheet,且没有标题
和背景颜色
。
`MKSActionSheetController* actionsheetController = [[MKSActionSheetController alloc] init];
[actionsheetController showActionsheetInController:self
title:nil //Actionsheet header title text
backgroundColor:nil //Actionsheet background color
cancelButtonTitle:@"CancelButton title" //Cancel button title text
button1Title:@"Button1 title" //Button1 title text
button2Title:nil //Button2 title text
cancelButtonColor:[UIColor lightGrayColor]//Cancel button title text color
button1Color:[UIColor darkGrayColor] //Button1 title text color
button2Color:nil //Button2 title text color
completionBlock:^(kActionsheetTappedButtonIndex index) {
//Dissmiss Actionsheet controller
[actionsheetController dismissActionsheet];
//Do appropriate action
}];`
它运行在iOS 7及以上的操作系统版本。
CustomActionsheet通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中。
pod 'CustomActionsheet'
Mohd Kamar Shad,[email protected]
CustomActionsheet可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。