Giter VIP home page Giter VIP logo

acactionsheet's Introduction

ACActionSheet - 一个简洁好用的ActionSheet/AlertView

GitHub license podversion

系统UIActionSheet其实挺好用的。但是有时候系统的风格跟APP有些不搭。而且在iOS8.0 UIKit更新了UIAlertController,苹果建议:UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead

ACActionSheet是仿微信效果的,简洁清新,方便好用

GitHub: https://github.com/GardenerYun

Email: [email protected]

简书博客地址: http://www.jianshu.com/users/8489e70e237d/latest_articles

如有问题或建议请联系我,我会马上解决问题~ (ง •̀_•́)ง**


2019年12月11日 更新 (v1.0.5)

1.优化逻辑,并支持CocoaPods: pod 'ACActionSheet'

2.新增类目UIAlertController+ACAlertView 为UIAlertController以UIAlertView(Deprecate)代码风格新增block初始化方法,详情见代码:

+ (instancetype)alertControllerWithTitle:(nullable NSString *)title
                                 message:(nullable NSString *)message
                       cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                      confirmButtonTitle:(nullable NSString *)confirmButtonTitle
                          preferredStyle:(UIAlertControllerStyle)preferredStyle
                          alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock;



+ (instancetype)alertControllerWithTitle:(nullable NSString *)title
                                 message:(nullable NSString *)message
                       cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                      confirmButtonTitle:(nullable NSString *)confirmButtonTitle
                       otherButtonTitles:(nullable NSArray <NSString *>*)otherButtonTitles
                          preferredStyle:(UIAlertControllerStyle)preferredStyle
                          alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock;

(v1.0.0)

  • 这是微信效果截图

ACAcitonSheet_03 ACAcitonSheet_01 ACAcitonSheet_02


  • 系统UIActionSheet (UIAlertController)gif 效果图

系统ActionSheet.gif


  • ACActionSheet gif 效果图

ACActionSheet.gif


代码示例

ACActionSheet尽力按照苹果UIKit代码风格编写。initWith...创建 -> show方法 -> delegate或block监听事件

  • delegate模式 创建
/**
 *  type delegate
 *
 *  @param title                  title            (可以为空)
 *  @param delegate               delegate
 *  @param cancelButtonTitle      "取消"按钮         (默认有)
 *  @param destructiveButtonTitle "警示性"(红字)按钮  (可以为空)
 *  @param otherButtonTitles      otherButtonTitles
 */
- (instancetype)initWithTitle:(NSString *)title
                     delegate:(id<ACActionSheetDelegate>)delegate
            cancelButtonTitle:(NSString *)cancelButtonTitle
       destructiveButtonTitle:(NSString *)destructiveButtonTitle
            otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
            
/***********************************************************************************/

ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:@"保存或删除数据" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"删除" otherButtonTitles:@"保存",@"更改", nil];

[actionSheet show];

#pragma mark - ACActionSheet delegate
- (void)actionSheet:(ACActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"ACActionSheet delegate - %ld",buttonIndex);
}
  • block模式 创建
typedef void(^ACActionSheetBlock)(NSInteger buttonIndex);

/**
 *  type block
 *
 *  @param title                  title            (可以为空)
 *  @param cancelButtonTitle      "取消"按钮         (默认有)
 *  @param destructiveButtonTitle "警示性"(红字)按钮  (可以为空)
 *  @param otherButtonTitles      otherButtonTitles
 *  @param actionSheetBlock       actionSheetBlock
 */
- (instancetype)initWithTitle:(NSString *)title
            cancelButtonTitle:(NSString *)cancelButtonTitle
       destructiveButtonTitle:(NSString *)destructiveButtonTitle
            otherButtonTitles:(NSArray *)otherButtonTitles
             actionSheetBlock:(ACActionSheetBlock) actionSheetBlock;
             
             
/***********************************************************************************/
ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@[@"小视频",@"拍照",@"从手机相册选择"] actionSheetBlock:^(NSInteger buttonIndex) {
        NSLog(@"ACActionSheet block - %ld",buttonIndex);
    }];
[actionSheet show];

acactionsheet's People

Contributors

gardeneryun avatar hitwist 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.