LPActionSheet
是一款輕量級(jí)的仿微信彈出框
安裝
從CocoaPods安裝
CocoaPods可以優(yōu)雅地管理第三方庫(具體使用方式我在另一篇文章有詳細(xì)介紹,這里不再贅述)
- 第一步: 在Podfile文件中寫入如下代碼
pod 'LPActionSheet', '~> 1.0'
- 第二步: 將文件安裝進(jìn)項(xiàng)目中
pod install
從Github上手動(dòng)添加
- 第一步: 到 這里 下載代碼文件,將LPActionSheet/LPActionSheet文件夾拖到項(xiàng)目中
- 第二步: 將頭文件加入項(xiàng)目中 #import "LPActionSheet.h"
如何使用LPActionSheet
你可以像這樣實(shí)例化一個(gè)對(duì)象 (該方法為指定初始化器,其他初始化方法都會(huì)調(diào)用該方法,NS_DESIGNATED_INITIALIZER)
- (instancetype)initWithTitle:(NSString *)title
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
handler:(LPActionSheetBlock)actionSheetBlock NS_DESIGNATED_INITIALIZER;
你可以像這樣快速返回一個(gè)實(shí)例化對(duì)象
+ (instancetype)actionSheetWithTitle:(NSString *)title
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
handler:(LPActionSheetBlock)actionSheetBlock;
使用如下方法彈出該視圖
- (void)show;
終極解決方案 (推薦)
+ (void)showActionSheetWithTitle:(NSString *)title
cancelButtonTitle:(NSString *)cancelButtonTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(NSArray *)otherButtonTitles
handler:(LPActionSheetBlock)actionSheetBlock;
Demo
[LPActionSheet showActionSheetWithTitle:@"This is a title, you can show some prompt here"
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Destructive"
otherButtonTitles:@[@"First choice", @"Second choice", @"Third choice"]
handler:^(LPActionSheet *actionSheet, NSInteger index) {
NSLog(@"%ld", index);
}];
豎屏
橫屏
后續(xù)更新
該框架后續(xù)會(huì)在Github上維護(hù)更新,歡迎關(guān)注