Coder Social home page Coder Social logo

dlxxl06 / lcactionsheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itofu/lcactionsheet

0.0 2.0 0.0 583 KB

一个简约优雅的ActionSheet。微信和新浪微博也是采取类似的ActionSheet。

Home Page: http://LeoDev.me

License: MIT License

Ruby 3.00% Objective-C 97.00%

lcactionsheet's Introduction

LCActionSheet

Travis CocoaPods CocoaPods CocoaPods LeoDev

一个简约优雅的 ActionSheet。微信和新浪微博也是采取类似的 ActionSheet。

image

In me the tiger sniffs the rose.

心有猛虎,细嗅蔷薇。

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

前言 Foreword

OK,这次我是看系统的 UIActionSheet 不爽。不能更改 tintColor (蓝蓝的其实也还看得过去)就算了,风格还跟自己的 App 极为不搭。

然后看了看微信和新浪微博的 ActionSheet,嗯,还不错。于是自己搞了个 ActionSheet,并发扬大庇天下码农俱欢颜的精神,放上来给大家用:)

代码 Code

  • 两个方法:

    • 方法一:CocoaPods 导入:pod 'LCActionSheet'
    • 方法二:把 LCActionSheet 文件夹(在 Demo 中)拖到你的项目中
  • 在相应位置导入头文件:#import "LCActionSheet.h",遵守协议 <LCActionSheetDelegate>

  • 调用下面的方法即可:

    // 1. 类方法 + Block
    LCActionSheet *sheet = [LCActionSheet sheetWithTitle:nil buttonTitles:@[@"拍照", @"从相册选择"] redButtonIndex:-1 clicked:^(NSInteger buttonIndex) {
    
        NSLog(@"> Block way -> Clicked Index: %ld", (long)buttonIndex);
    }];
    
    [sheet show];
    
    
    // 2. 实例方法 + Delegate + 添加按钮
    LCActionSheet *sheet = [[LCActionSheet alloc] initWithTitle:@"你确定要注销吗?"
                                                   buttonTitles:nil
                                                 redButtonIndex:0
                                                       delegate:self];
    
    [sheet addButtonTitle:@"确定"];
    
    [sheet show];
  • 监听方法 (代理方法,可选实现):

    - (void)actionSheet:(LCActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex;
  • 自定义实现 (By zachgenius)

    LCActionSheet* sheet = [[LCActionSheet alloc] init];
    
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    
    if (version < 8.0) {
    
        [sheet addButtonTitle:@"iOS 7.x"];
    
    } else {
    
        [sheet addButtonTitle:@"iOS 8+"];
    }
    
    sheet.clickedBlock = ^(NSInteger buttonIndex) {
    
        NSLog(@"Hello %ld!", (long)buttonIndex);
    };
    
    [sheet show];
    

TODO

  • 使用 CALayer 优化性能
  • 使用约束布局
  • 支持横排

更新日志 Update Logs

2016.03.07 (Tag: 1.2.0)

  • 合并 PR by apache2046,致谢!

    Swift bug fixed

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

2016.02.17 (Tag: 1.1.5)

  • 合并 PR by nix1024,致谢!

    Add background opacity & animation duration option

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

2015.12.16 (Tag: 1.1.3)

  • 合并 PR by zachgenius,致谢!

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

  • V 1.1.2 被怪物吃掉了!👹

2015.12.09 (Tag: 1.1.1)

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

2015.12.07 (Tag: 1.1.0)

  • 要 Block?满足你!

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

2015.11.09 (Tag: 1.0.6)

  • 添加对 CocoaPods 的支持:

    pod 'LCActionSheet'

2015.05.08 (Tag: 1.0.0)

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

2015.05.08 (Tag: 1.0.0)

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

2015.05.05 (Tag: 1.0.0)

  • 我还是没有适配横屏(´Д`)
  • 增加了类方法,可以通过类方法实例化 actionSheet。
  • 完善部分注释。

提示 Tips

  • LCActionSheet 是添加到当前的 Window 上,没适配横屏。
  • 提供了 title、buttons、redButton、cancelBtn 这些杂七杂八的东东,应该全了。
  • buttonIndex 从上到下从 0 依次递增。如果不想有 redButton,在 redButtonIndex: 处传 -1 即可。
  • 协议 <LCActionSheetDelegate> 能监听到点击的按钮的 index,这个方法是可选实现的。

鸣谢 Thanks

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

示例 Examples

image

image

联系 Support

Alipay

授权 License

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

Bitdeli Badge

lcactionsheet's People

Contributors

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

Watchers

James Cloos avatar  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.