GithubHelp home page GithubHelp logo

wyb520 / lcactionsheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itofu/lcactionsheet

0.0 2.0 0.0 558 KB

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

Home Page: http://LeoDev.me

License: MIT License

Ruby 3.31% Objective-C 96.69%

lcactionsheet's Introduction

LCActionSheet

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

image

心有猛虎,细嗅蔷薇。

欢迎访问 我的博客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:@[@"确定"]
                                             redButtonIndex:0 
                                                   delegate:self];

[sheet show];
  • 监听方法(代理方法,可选实现):
- (void)actionSheet:(LCActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex;

TODO

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

更新日志 2015.12.09 Update Logs (Tag: 1.1.1)

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

更新日志 2015.12.07 Update Logs (Tag: 1.1.0)

  • 要 Block?满足你!
  • 优化逻辑:创建 ActionSheet 时,不再添加到 window 上。

更新日志 2015.11.09 Update Logs (Tag: 1.0.6)

  • 添加对 CocoaPods 的支持:pod 'LCActionSheet'

更新日志 2015.05.08 Update Logs (Tag: 1.0.0)

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

更新日志 2015.05.08 Update Logs (Tag: 1.0.0)

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

更新日志 2015.05.05 Update Logs (Tag: 1.0.0)

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

提示 Tips

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

示例 Examples

image

image

联系 Support

授权 License

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

lcactionsheet's People

Contributors

itofu 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.