UI效果iOS/Swift第三方库使用推送

iOS仿微信弹出框LPActionSheet

2016-08-12  本文已影响1824人  蚊香酱

LPActionSheet是一款轻量级的仿微信弹出框

安装

从CocoaPods安装

CocoaPods可以优雅地管理第三方库(具体使用方式我在另一篇文章有详细介绍,这里不再赘述)

pod 'LPActionSheet', '~> 1.0'
pod install
从Github上手动添加

如何使用LPActionSheet

你可以像这样实例化一个对象 (该方法为指定初始化器,其他初始化方法都会调用该方法,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

后续更新

该框架后续会在Github上维护更新,欢迎关注

https://github.com/wenxiangjiang/LPActionSheet

上一篇 下一篇

猜你喜欢

热点阅读