iOS仿微信彈出框LPActionSheet

LPActionSheet是一款輕量級的仿微信彈出框

安裝

從CocoaPods安裝

CocoaPods可以優(yōu)雅地管理第三方庫(具體使用方式我在另一篇文章有詳細介紹,這里不再贅述)

  • 第一步: 在Podfile文件中寫入如下代碼
pod 'LPActionSheet', '~> 1.0'
  • 第二步: 將文件安裝進項目中
pod install
從Github上手動添加
  • 第一步: 到 這里 下載代碼文件,將LPActionSheet/LPActionSheet文件夾拖到項目中
  • 第二步: 將頭文件加入項目中 #import "LPActionSheet.h"

如何使用LPActionSheet

你可以像這樣實例化一個對象 (該方法為指定初始化器,其他初始化方法都會調(diào)用該方法,NS_DESIGNATED_INITIALIZER)

- (instancetype)initWithTitle:(NSString *)title
            cancelButtonTitle:(NSString *)cancelButtonTitle
       destructiveButtonTitle:(NSString *)destructiveButtonTitle
            otherButtonTitles:(NSArray *)otherButtonTitles
                      handler:(LPActionSheetBlock)actionSheetBlock NS_DESIGNATED_INITIALIZER;

你可以像這樣快速返回一個實例化對象

+ (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);
}];

豎屏

LPActionSheet.png

橫屏

LPActionSheet_Landscape.png

后續(xù)更新

該框架后續(xù)會在Github上維護更新,歡迎關(guān)注

https://github.com/wenxiangjiang/LPActionSheet

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容