Giter Site home page Giter Site logo

juxiaohui / lcactionsheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itofu/lcactionsheet

0.0 2.0 0.0 15.82 MB

一款简约而不失强大的 ActionSheet,微信和微博都采取了极其类似的样式。

Home Page: http://LeoDev.me

License: MIT License

Ruby 2.35% Objective-C 97.65%

lcactionsheet's Introduction

LCActionSheet

Travis CocoaPods CocoaPods CocoaPods LeoDev

☀️ 一款简约而不失强大的 ActionSheet,微信和微博都采取了极其类似的样式。

LCActionSheet

如果上图没打开,直接前往 Demo 图地址

In me the tiger sniffs the rose.

心有猛虎,细嗅蔷薇。

欢迎访问我的博客:http://LeoDev.me

介绍 Introduction

☀️ 一款简约而不失强大的 ActionSheet,微信和微博都采取了极其类似的样式。

  • iOS 7.0 +,Demo 需要 CocoaPods 环境运行。

  • 格调高雅,风格百搭,怎么看怎么舒服。

  • 高度自定义,可能需要自定义的基本都考虑到了。详见 LCActionSheet.h Properties 部分。

  • 有代理,有 Block,可类方法,可实例方法,想怎样,就怎样。

  • 代理、Block 非常完善,从 will 到 did 都有,详见 LCActionSheet.h Delegate & Block 部分。

  • 支持 iPad,支持横屏,支持竖屏,支持一会横屏一会竖屏,支持超长标题,理论上支持无数个按钮,统统支持。

  • 注释完整,代码风格良好,善意满满,便于阅读源码,照顾强迫症,拓展更多功能请前往 PR。三个诸葛亮,顶个好工匠。

  • 集百家之长,使用 Masonry 进行布局,感谢 Masonry

  • 有骨气。就不改状态栏颜色,就是这么刚。

💬 告示

英文还不错时间又充裕的同学可以帮我翻译出 README 的英文版,我好往 CocoaControls 上扔啊~

可白文翻译,使用 Markdown 编辑更佳!义务的哦,如果翻译用心的话我个人请你喝杯咖啡 ☕️!

直接 PR 或者发我邮箱:[email protected] 都可!

代码 Code

  • 两种导入方法:

    • 方法一:CocoaPodspod 'LCActionSheet'

    • 方法二:直接把 LCActionSheet 文件夹(在 Demo 中)拖拽到你的项目中

  • 在相应位置导入头文件:#import "LCActionSheet.h",遵守协议 <LCActionSheetDelegate>

  • 调用列的任意方法即可:

    1. 默认样式,迅速搞定
    LCActionSheet *actionSheet = [LCActionSheet sheetWithTitle:@"Default LCActionSheet"
                                                      delegate:self
                                             cancelButtonTitle:@"Cancel"
                                             otherButtonTitles:@"Button 1", @"Button 2", @"Button 3", nil];
    [actionSheet show];
    1. 可自定义项,LCActionSheet.h 中有完整注释
    LCActionSheet *actionSheet     = [[LCActionSheet alloc] initWithTitle:nil
                                                                 delegate:self
                                                        cancelButtonTitle:@"Cancel"
                                                        otherButtonTitles:@"Button 1", @"Button 2", @"Button 3", @"Button 4", @"Button 5", nil];
    actionSheet.title              = @"This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very long title~";
    actionSheet.cancelButtonTitle  = @"Close";
    [actionSheet appendButtonTitles:@"Button 6", @"Button 7", nil];
    actionSheet.titleColor         = [UIColor orangeColor];
    actionSheet.buttonColor        = [UIColor greenColor];
    actionSheet.titleFont          = [UIFont boldSystemFontOfSize:15.0f];
    actionSheet.buttonFont         = [UIFont boldSystemFontOfSize:15.0f];
    actionSheet.buttonHeight       = 60.0f;
    actionSheet.scrolling          = YES;
    actionSheet.visibleButtonCount = 3.6f;
    actionSheet.darkViewNoTaped    = YES;
    actionSheet.unBlur             = YES;
    actionSheet.blurEffectStyle    = UIBlurEffectStyleLight;
    
    // V 2.1.0 use `destructiveButtonIndexSet` instead of `redButtonIndexSet`.
    actionSheet.destructiveButtonIndexSet = [NSSet setWithObjects:@0, @2, nil];
    actionSheet.destructiveButtonColor    = [UIColor blueColor];
    
    [actionSheet show];
    1. Block
    LCActionSheet *actionSheet = [LCActionSheet sheetWithTitle:@"Block LCActionSheet" cancelButtonTitle:@"Cancel" clicked:^(LCActionSheet *actionSheet, NSInteger buttonIndex) {
        
        NSLog(@"clickedButtonAtIndex: %d", (int)buttonIndex);
        
    } otherButtonTitles:@"Button 1", @"Button 2", @"Button 3", @"Button 4", @"Button 5", @"Button 6", nil];
    
    // actionSheet.blurEffectStyle = UIBlurEffectStyleLight;
    
    actionSheet.scrolling          = YES;
    actionSheet.visibleButtonCount = 3.6f;
    
    actionSheet.willPresentBlock = ^(LCActionSheet *actionSheet) {
        NSLog(@"willPresentActionSheet");
    };
    
    actionSheet.didPresentBlock = ^(LCActionSheet *actionSheet) {
        NSLog(@"didPresentActionSheet");
    };
    
    actionSheet.willDismissBlock = ^(LCActionSheet *actionSheet, NSInteger buttonIndex) {
        NSLog(@"willDismissWithButtonIndex: %d", (int)buttonIndex);
    };
    
    actionSheet.didDismissBlock = ^(LCActionSheet *actionSheet, NSInteger buttonIndex) {
        NSLog(@"didDismissWithButtonIndex: %d", (int)buttonIndex);
    };
    
    [actionSheet show];
    1. Delegate,可选实现
    #pragma mark - LCActionSheet Delegate
    
    - (void)actionSheet:(LCActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        NSLog(@"clickedButtonAtIndex: %d", (int)buttonIndex);
    }
    
    - (void)willPresentActionSheet:(LCActionSheet *)actionSheet {
        NSLog(@"willPresentActionSheet");
    }
    
    - (void)didPresentActionSheet:(LCActionSheet *)actionSheet {
        NSLog(@"didPresentActionSheet");
    }
    
    - (void)actionSheet:(LCActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
        NSLog(@"willDismissWithButtonIndex: %d", (int)buttonIndex);
    }
    
    - (void)actionSheet:(LCActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
        NSLog(@"didDismissWithButtonIndex: %d", (int)buttonIndex);
    }

使用者 Cases

你可以在这里查看本框架的大部分集成统计:CocoaPods 统计

下表列举了使用本框架的部分 App:

名称 简介
PrPr直播 一个略萌的二次元直播平台
德玛西亚 一款 英雄联盟© 周边 App
揽梦云签 考勤打卡 + 移动办公
... ...

上表仅用作统计和效果参考,如果你的项目中使用了本框架并希望加入上表,请发邮件到 [email protected] 或者 新建一个 Issue 告诉我你的应用名称和应用链接,我会尽快添加 :)

版本 ChangeLog

V 2.6.0 (2016.10.22)

  • 修复取消按钮不显示时 UI 上的一个 Bug。另外你可以通过设置 cancelButtonTitlenil@"" 来不显示取消按钮,这是一个 Tip,并不是一个 Feature。。。

  • 修正一些逻辑:

    • cancelButtonIndex 始终返回 0

    • 除取消按钮以外的按钮自上而下 Index 从 1 递增。也就是说,无论取消按钮是否显示,Index 0 始终会被取消按钮占有。

V 2.5.2 (2016.09.23)

  • 注: 因 CocoaPods 对 Xcode 8 的一些问题(Issue 5661Issue 5843...),暂时无法推到 CocoaPods Repo,你需要在 Podfile 进行如下的修改,直接指向当前版本即可:

 # 不需要了,作者借了个 Xcode 7 的电脑去更新了。。。 pod 'LCActionSheet' # , :git => 'https://github.com/iTofu/LCActionSheet.git'


* 修复一个影响用户体验的效果,详见:[Issue 25](https://github.com/iTofu/LCActionSheet/issues/25)。

* 完善剩下的部分注释,主要是 Block 部分。


### V 2.5.1 (2016.09.08)

* 修复一个更换字体失效的 Bug。


### V 2.5.0 (2016.09.05 ⚠️ 属性名变化)

* 添加 `cancenButtonIndex` 属性,始终返回 `0`:

```objc
@interface LCActionSheet : UIView

@property (nonatomic, assign, readonly) NSInteger cancelButtonIndex;
  • 修改 Block 属性命名:

    @property (nonatomic, copy) LCActionSheetClickedBlock     clickedBlock;
    @property (nonatomic, copy) LCActionSheetWillPresentBlock willPresentBlock;
    @property (nonatomic, copy) LCActionSheetDidPresentBlock  didPresentBlock;
    @property (nonatomic, copy) LCActionSheetWillDismissBlock willDismissBlock;
    @property (nonatomic, copy) LCActionSheetDidDismissBlock  didDismissBlock;
    
    ->
    
    @property (nonatomic, copy) LCActionSheetClickedHandle     clickedHandle;
    @property (nonatomic, copy) LCActionSheetWillPresentHandle willPresentHandle;
    @property (nonatomic, copy) LCActionSheetDidPresentHandle  didPresentHandle;
    @property (nonatomic, copy) LCActionSheetWillDismissHandle willDismissHandle;
    @property (nonatomic, copy) LCActionSheetDidDismissHandle  didDismissHandle;

V 2.3.3 (2016.08.16)

  • 修复设置 actionSheet.unBlur = YES; 后背景透明的 Bug。

  • 完善注释,移除无用类。

V 2.3.2 (2016.08.16)

  • 可以自定义 blurEffectStyle:

    @property (nonatomic, assign) UIBlurEffectStyle blurEffectStyle;

V 2.3.1 (2016.08.15)

  • 静态渲染模糊改为模糊蒙板。

V 2.3.0 (2016.08.11)

  • 重新实现 V 1.x 的方法,允许使用数组而不必须是多参数来设置按钮标题:

    #pragma mark Delegate
    
    + (instancetype)sheetWithTitle:(NSString *)title
                          delegate:(id<LCActionSheetDelegate>)delegate
                 cancelButtonTitle:(NSString *)cancelButtonTitle
             otherButtonTitleArray:(NSArray *)otherButtonTitleArray;
    
    - (instancetype)initWithTitle:(NSString *)title
                         delegate:(id<LCActionSheetDelegate>)delegate
                cancelButtonTitle:(NSString *)cancelButtonTitle
            otherButtonTitleArray:(NSArray *)otherButtonTitleArray;
    
    
    #pragma mark Block
    
    + (instancetype)sheetWithTitle:(NSString *)title
                 cancelButtonTitle:(NSString *)cancelButtonTitle
                           clicked:(LCActionSheetClickedBlock)clickedBlock
             otherButtonTitleArray:(NSArray *)otherButtonTitleArray;
    
    - (instancetype)initWithTitle:(NSString *)title
                cancelButtonTitle:(NSString *)cancelButtonTitle
                          clicked:(LCActionSheetClickedBlock)clickedBlock
            otherButtonTitleArray:(NSArray *)otherButtonTitleArray;
  • 优化一些 UI 效果,主要是高亮状态的效果。

V 2.2.0 (2016.07.27)

V 2.1.1 (2016.07.19)

  • 完善部分注释,注明需要注明的属性的默认值。

V 2.1.0 (2016.07.19)

  • 新增自定义项,Issue 18 by IAMJ

    destructiveButtonColor // 警示按钮颜色
  • 修改一个属性命名:

    // 与 UIActionSheet 命名保持一致,便于顺手敲出
    // V 2.1.0 给予 redButtonIndexSet 过期警告,下一版本将会移除该属性
    redButtonIndexSet -> destructiveButtonIndexSet

V 2.0.0 (2016.07.16, ⚠️ Important)

  • 彻底重构整个项目,满足目前收到的所有需求,功能只多不少,依然 MIT 共享。

  • 现已加入 Masonry 豪华套餐。

V 1.2.3 (2016.04.05)

  • 更新 CocoaPods 源地址。

V 1.2.0 (2016.03.07)

  • 合并 PR by apache2046,致谢!

    Swift bug fixed

    mainBundle 这种方法无法在将 LCActionSheet 作为 Framework 时正确找到资源包路径

V 1.1.5 (2016.02.17)

  • 合并 PR by nix1024,致谢!

    Add background opacity & animation duration option

    添加暗黑背景透明度和动画持续时间的设定

V 1.1.3 (2015.12.16)

  • 合并 PR by zachgenius,致谢!

    增加了一些功能实现,如增加自定义添加按钮的方法,增加按钮本地化,增加自定义按钮颜色,并且优化逻辑。

  • V 1.1.2 被怪物吃掉了!👹

V 1.1.1 (2015.12.09)

  • 标题支持最多两行。两行时会适当调整标题的背景高度。

V 1.1.0 (2015.12.07)

  • 要 Block?满足你!

  • 优化逻辑:创建 ActionSheet 时,不再添加到 window 上。

V 1.0.6 (2015.11.09)

  • 添加对 CocoaPods 的支持:

    pod 'LCActionSheet'

V 1.0.0 (2015.05.08)

  • 修复:新添加的 _backWindow 在某些情况下导致界面无反应的BUG。——by kuanglijun312

  • 修复:当 StatusBarStyle 为 UIStatusBarStyleLightContent 时,背景不会遮挡 statusBar 的问题。——by 陈威

V 1.0.0 pre (2015.05.05)

  • 增加了类方法,可以通过类方法实例化 actionSheet。

  • 完善部分注释。

提示 Tips

  • LCActionSheet 添加到 KeyWindow 上,已适配横屏。

  • 可自定义 title、buttons、destructiveButtons、cancelButton、titleColor、titleFont、buttonColor、buttonFont、canScrolling 等等,详见 LCActionSheet.h

  • 点击的 buttonIndex 按 UIAlertView 的逻辑来即可,若有取消按钮则取消按钮为 0,其他从上至下递增。

  • scrolling 属性控制按钮过多时,是否可以滚动,默认 NO,不可滚动。visibleButtonCount 属性控制可见的按钮个数,可以是小数,必须先设置 scrolling = YES 才生效。tableView 的 scrollsToTop 属性依然可用,可点击状态栏快速滚回顶部。

鸣谢 Thanks

  • Masonry

  • 海纳百川,有容乃大。感谢开源社区和众攻城狮的支持!感谢众多 IssuesPR!更期待你的 PR

示例 Examples

LCActionSheet


LCActionSheet


LCActionSheet

联系 Support

授权 License

本项目采用 MIT license 开源,你可以利用采用该协议的代码做任何事情,只需要继续继承 MIT 协议即可。

lcactionsheet's People

Contributors

itofu avatar zachgenius avatar bitdeli-chef avatar apache2046 avatar weiwei1035 avatar

Watchers

James Cloos avatar juxiaohui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.