iOS仿微信弹出框LPActionSheet

作者: 蚊香酱 | 来源:发表于2016-08-12 22:35 被阅读1824次

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

安装

从CocoaPods安装

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

  • 第一步: 在Podfile文件中写入如下代码
pod 'LPActionSheet', '~> 1.0'
  • 第二步: 将文件安装进项目中
pod install
从Github上手动添加
  • 第一步: 到 这里 下载代码文件,将LPActionSheet/LPActionSheet文件夹拖到项目中
  • 第二步: 将头文件加入项目中 #import "LPActionSheet.h"

如何使用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

相关文章

  • iOS仿微信弹出框LPActionSheet

    LPActionSheet是一款轻量级的仿微信弹出框 安装 从CocoaPods安装 CocoaPods可以优雅地...

  • 实用框架

    2.模仿微信的底部弹框https://github.com/wenxiangjiang/LPActionSheet...

  • iOS仿微信弹出框链式语法

    仿写的微信弹出框 使用方法 传送门:github地址:https://github.com/zombieEngin...

  • iOS 仿微信、微博底部弹出选项框

    由于项目中经常使用,封装了一个简单的底部弹出框控件,可以自定义一下属性,希望可以帮到需要的朋友。 GitHub地址...

  • 仿微信、QQ左侧弹出框

    1、本方法已经支持pod后续将不断更新更多样弹出框功能 pod地址:https://github.com/9747...

  • ios 让项目支持cocoapod

    一、让自己的开源项目支持CocoaPodsXJActionSheet 是我仿写的类微信底部弹出框,以它为例子! 在...

  • Android 仿IOS弹出框

    输入型弹出框 在他人代码基础上进行了修改,实现 可输入式弹出框 public class AlertInputTe...

  • Android 仿IOS弹出框

    输入型弹出框 在他人代码基础上进行了修改,实现 可输入式弹出框 布局 view_alert_input_tsxt...

  • iOS 开发之仿微信输入框

    仿微信输入框的要点:1.输入框自适应高度 2.轻触弹出菜单可换行 首先需要写一个自定义输入框,可设置提示文字及颜色...

  • 仿微信底部弹出

    一个简单的微信底部弹出,使用简单,方便扩展。

网友评论

本文标题:iOS仿微信弹出框LPActionSheet

本文链接:https://www.haomeiwen.com/subject/adsesttx.html