├── ACActionSheet.podspec ├── ACActionSheet ├── ACActionSheet.bundle │ └── actionSheetHighLighted@2x.png ├── ACActionSheet.h ├── ACActionSheet.m └── ACAlertView │ ├── UIAlertController+ACAlertView.h │ └── UIAlertController+ACAlertView.m ├── ACActionSheetDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── Acha.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Acha.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ACActionSheetDemo.xcscheme │ └── xcschememanagement.plist ├── ACActionSheetDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE └── README.md /ACActionSheet.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = 'ACActionSheet' 4 | s.version = '1.0.6' 5 | s.summary = 'An easy way to use actionSheet/alertView' 6 | 7 | s.homepage = 'https://github.com/GardenerYun' 8 | s.license = { :type => 'MIT', :file => 'LICENSE' } 9 | s.author = { '章子云' => 'gardeneryun@foxmail.com' } 10 | s.source = { :git => 'https://github.com/GardenerYun/ACActionSheet.git', :tag => s.version} 11 | 12 | s.ios.deployment_target = '8.0' 13 | 14 | s.source_files = 'ACActionSheet/**/*.{h,m}' 15 | s.resource = 'ACActionSheet/ACActionSheet.bundle' 16 | s.requires_arc = true 17 | s.frameworks = 'UIKit', 'Foundation' 18 | 19 | end 20 | -------------------------------------------------------------------------------- /ACActionSheet/ACActionSheet.bundle/actionSheetHighLighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GardenerYun/ACActionSheet/fe32e0ce876e6354f9a0461f2b26dfb21a137b81/ACActionSheet/ACActionSheet.bundle/actionSheetHighLighted@2x.png -------------------------------------------------------------------------------- /ACActionSheet/ACActionSheet.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACActionSheet.h 3 | // ACActionSheetDemo 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | // GitHub: https://github.com/GardenerYun 9 | // Email: gardeneryun@foxmail.com 10 | // 简书博客地址: http://www.jianshu.com/users/8489e70e237d/latest_articles 11 | // 如有问题或建议请联系我,我会马上解决问题~ (ง •̀_•́)ง 12 | // 13 | 14 | #define ACScreenWidth [UIScreen mainScreen].bounds.size.width 15 | #define ACScreenHeight [UIScreen mainScreen].bounds.size.height 16 | #define ACRGB(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1] 17 | #define ACButtonTitleFont [UIFont systemFontOfSize:17.0f] 18 | 19 | #define ACTitleHeight 66.0f 20 | #define ACButtonHeight 55.0f 21 | #define ACSeparatorViewHeight 7.0f 22 | #define ACWeakSelf __weak typeof(self) weakSelf = self; 23 | 24 | #define ACViewCornerRadius 10.0f 25 | 26 | #define ACDarkShadowViewAlpha 0.35f 27 | 28 | #define ACShowAnimateDuration 0.4f 29 | #define ACHideAnimateDuration 0.2f 30 | 31 | /// 竖屏底部安全区域 32 | #define ACSafeAreaHeight \ 33 | ({CGFloat bottom=0.0;\ 34 | if (@available(iOS 11.0, *)) {\ 35 | bottom = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom;\ 36 | } else { \ 37 | bottom=0;\ 38 | }\ 39 | (bottom);\ 40 | }) 41 | 42 | 43 | #import 44 | 45 | @protocol ACActionSheetDelegate; 46 | 47 | typedef void(^ACActionSheetBlock)(NSInteger buttonIndex); 48 | 49 | @interface ACActionSheet : UIView 50 | 51 | /** 52 | * type delegate 53 | * 54 | * @param title title (可以为空) 55 | * @param delegate delegate 56 | * @param cancelButtonTitle "取消"按钮 (默认有) 57 | * @param destructiveButtonTitle "警示性"(红字)按钮 (可以为空) 58 | * @param otherButtonTitles otherButtonTitles 59 | */ 60 | - (instancetype)initWithTitle:(NSString *)title 61 | delegate:(id)delegate 62 | cancelButtonTitle:(NSString *)cancelButtonTitle 63 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 64 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 65 | 66 | /** 67 | * type block 68 | * 69 | * @param title title (可以为空) 70 | * @param cancelButtonTitle "取消"按钮 (默认有) 71 | * @param destructiveButtonTitle "警示性"(红字)按钮 (可以为空) 72 | * @param otherButtonTitles otherButtonTitles 73 | * @param actionSheetBlock actionSheetBlock 74 | */ 75 | - (instancetype)initWithTitle:(NSString *)title 76 | cancelButtonTitle:(NSString *)cancelButtonTitle 77 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 78 | otherButtonTitles:(NSArray *)otherButtonTitles 79 | actionSheetBlock:(ACActionSheetBlock)actionSheetBlock; 80 | 81 | 82 | @property (nonatomic, copy) NSString *title; 83 | @property (nonatomic, weak) id delegate; 84 | 85 | - (void)show; 86 | 87 | @end 88 | 89 | 90 | #pragma mark - ACActionSheet delegate 91 | 92 | @protocol ACActionSheetDelegate 93 | 94 | @optional 95 | 96 | - (void)actionSheet:(ACActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex; 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /ACActionSheet/ACActionSheet.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACActionSheet.m 3 | // ACActionSheetDemo 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | // GitHub: https://github.com/GardenerYun 9 | // Email: gardeneryun@foxmail.com 10 | // 简书博客地址: http://www.jianshu.com/users/8489e70e237d/latest_articles 11 | // 如有问题或建议请联系我,我会马上解决问题~ (ง •̀_•́)ง 12 | // 13 | 14 | #import "ACActionSheet.h" 15 | 16 | 17 | 18 | @interface ACActionSheet () 19 | 20 | @property (nonatomic, copy) NSString *cancelButtonTitle; 21 | @property (nonatomic, copy) NSString *destructiveButtonTitle; 22 | @property (nonatomic, copy) NSArray *otherButtonTitles; 23 | 24 | @property (nonatomic, strong) UIView *buttonBackgroundView; 25 | @property (nonatomic, strong) UIView *darkShadowView; 26 | 27 | @property (nonatomic, strong) UIScrollView *scrollView; 28 | 29 | @property (nonatomic, copy) ACActionSheetBlock actionSheetBlock; 30 | 31 | @end 32 | 33 | @implementation ACActionSheet 34 | #pragma mark - Life Cycle 35 | - (instancetype)initWithTitle:(NSString *)title 36 | delegate:(id)delegate 37 | cancelButtonTitle:(NSString *)cancelButtonTitle 38 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 39 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION { 40 | 41 | self = [super init]; 42 | if(self) { 43 | _title = title; 44 | _delegate = delegate; 45 | _cancelButtonTitle = cancelButtonTitle.length>0 ? cancelButtonTitle : @"取消"; 46 | _destructiveButtonTitle = destructiveButtonTitle; 47 | 48 | NSMutableArray *args = [NSMutableArray array]; 49 | 50 | if(_destructiveButtonTitle.length) { 51 | [args addObject:_destructiveButtonTitle]; 52 | } 53 | 54 | [args addObject:otherButtonTitles]; 55 | 56 | if (otherButtonTitles) { 57 | va_list params; 58 | va_start(params, otherButtonTitles); 59 | id buttonTitle; 60 | while ((buttonTitle = va_arg(params, id))) { 61 | if (buttonTitle) { 62 | [args addObject:buttonTitle]; 63 | } 64 | } 65 | va_end(params); 66 | } 67 | 68 | _otherButtonTitles = [NSArray arrayWithArray:args]; 69 | 70 | [self _initSubViews]; 71 | } 72 | 73 | return self; 74 | } 75 | 76 | 77 | - (instancetype)initWithTitle:(NSString *)title 78 | cancelButtonTitle:(NSString *)cancelButtonTitle 79 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 80 | otherButtonTitles:(NSArray *)otherButtonTitles 81 | actionSheetBlock:(ACActionSheetBlock)actionSheetBlock { 82 | 83 | self = [super init]; 84 | if(self) { 85 | _title = title; 86 | _cancelButtonTitle = cancelButtonTitle.length>0 ? cancelButtonTitle : @"取消"; 87 | _destructiveButtonTitle = destructiveButtonTitle; 88 | 89 | NSMutableArray *titleArray = [NSMutableArray array]; 90 | if (_destructiveButtonTitle.length) { 91 | [titleArray addObject:_destructiveButtonTitle]; 92 | } 93 | [titleArray addObjectsFromArray:otherButtonTitles]; 94 | _otherButtonTitles = [NSArray arrayWithArray:titleArray]; 95 | self.actionSheetBlock = actionSheetBlock; 96 | 97 | [self _initSubViews]; 98 | } 99 | 100 | return self; 101 | 102 | } 103 | 104 | #pragma mark - init/Create Methods 105 | - (void)_initSubViews { 106 | 107 | self.frame = CGRectMake(0, 0, ACScreenWidth, ACScreenHeight); 108 | self.backgroundColor = [UIColor clearColor]; 109 | self.hidden = YES; 110 | 111 | /// 透明灰色蒙版 112 | _darkShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ACScreenWidth, ACScreenHeight)]; 113 | _darkShadowView.backgroundColor = ACRGB(20, 20, 20); 114 | _darkShadowView.alpha = 0.0f; 115 | [self addSubview:_darkShadowView]; 116 | /// 透明灰色蒙版 添加点击手势 117 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_dismissViewAction:)]; 118 | [_darkShadowView addGestureRecognizer:tap]; 119 | 120 | /// 所有按钮父视图 121 | _buttonBackgroundView = [[UIView alloc] initWithFrame:CGRectZero]; 122 | _buttonBackgroundView.backgroundColor = ACRGB(240, 240, 240); 123 | [self addSubview:_buttonBackgroundView]; 124 | _buttonBackgroundView.layer.cornerRadius = ACViewCornerRadius; 125 | _buttonBackgroundView.clipsToBounds = YES; 126 | 127 | 128 | [self _initNormalButtons]; 129 | 130 | } 131 | 132 | 133 | 134 | /// 初始化常规类型actionSheet 135 | - (void)_initNormalButtons { 136 | /// 创建标题 137 | CGFloat titleLabelHeight = 0; 138 | if (self.title.length) { 139 | titleLabelHeight = ACTitleHeight; 140 | UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 141 | 0, 142 | ACScreenWidth, 143 | titleLabelHeight)]; 144 | titleLabel.text = _title; 145 | titleLabel.numberOfLines = 0; 146 | titleLabel.textColor = ACRGB(125, 125, 125); 147 | titleLabel.textAlignment = NSTextAlignmentCenter; 148 | titleLabel.font = [UIFont systemFontOfSize:14.0f]; 149 | titleLabel.backgroundColor = [UIColor whiteColor]; 150 | [_buttonBackgroundView addSubview:titleLabel]; 151 | 152 | UIView *line = [[UIView alloc] initWithFrame:CGRectZero]; 153 | line.backgroundColor = ACRGB(230, 230, 230); 154 | line.frame = CGRectMake(0, titleLabelHeight-1, ACScreenWidth, 0.5); 155 | [_buttonBackgroundView addSubview:line]; 156 | } 157 | 158 | /// 使用ScrollView展示button 159 | /// 计算button个数,大于限制则表格可滑动. 小于等于限制个数则直接展示不可滑动 160 | [self.buttonBackgroundView addSubview:self.scrollView]; 161 | NSInteger maxCount = ACScreenHeight/ACButtonHeight * 0.7; 162 | NSInteger showListCount = _otherButtonTitles.count; 163 | 164 | if (showListCount > maxCount) { 165 | showListCount = maxCount; 166 | self.scrollView.scrollEnabled = YES; 167 | self.scrollView.showsVerticalScrollIndicator = YES; 168 | } else { 169 | self.scrollView.scrollEnabled = NO; 170 | self.scrollView.showsVerticalScrollIndicator = NO; 171 | } 172 | 173 | self.scrollView.frame = CGRectMake(0, titleLabelHeight, ACScreenWidth, showListCount*ACButtonHeight); 174 | [self.scrollView setContentSize:CGSizeMake(ACScreenWidth, _otherButtonTitles.count*ACButtonHeight)]; 175 | self.scrollView.contentOffset = CGPointMake(0, 0); 176 | self.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); 177 | if (@available(iOS 11.0, *)) { 178 | self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 179 | } else { 180 | 181 | } 182 | 183 | /// 创建Button 184 | for (int i = 0; i < _otherButtonTitles.count; i++) { 185 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 186 | button.tag = i; 187 | [button setTitle:_otherButtonTitles[i] forState:UIControlStateNormal]; 188 | button.backgroundColor = [UIColor whiteColor]; 189 | button.titleLabel.font = ACButtonTitleFont; 190 | [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 191 | /// 如果有红色警示按钮 192 | if (i==0 && _destructiveButtonTitle.length) { 193 | [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 194 | } 195 | UIImage *image = [UIImage imageWithContentsOfFile:[[self _acBundle] pathForResource:@"actionSheetHighLighted@2x" ofType:@"png"]]; 196 | [button setBackgroundImage:image forState:UIControlStateHighlighted]; 197 | [button addTarget:self action:@selector(_didClickButton:) forControlEvents:UIControlEventTouchUpInside]; 198 | CGFloat buttonY = ACButtonHeight * i; 199 | button.frame = CGRectMake(0, buttonY, ACScreenWidth, ACButtonHeight); 200 | [self.scrollView addSubview:button]; 201 | 202 | UIView *line = [[UIView alloc] initWithFrame:CGRectZero]; 203 | line.backgroundColor = ACRGB(230, 230, 230); 204 | line.frame = CGRectMake(0, buttonY, ACScreenWidth, 0.5); 205 | /// 第一个不添加分割线 206 | if (i!=0) { 207 | [self.scrollView addSubview:line]; 208 | } 209 | } 210 | 211 | /// 分割View 212 | CGFloat separatorViewY = titleLabelHeight + ACButtonHeight * showListCount; 213 | 214 | UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(0, separatorViewY, ACScreenWidth, ACSeparatorViewHeight)]; 215 | separatorView.backgroundColor = ACRGB(240, 240, 240); 216 | [_buttonBackgroundView addSubview:separatorView]; 217 | 218 | /// 创建取消Button 219 | UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; 220 | cancelButton.frame = CGRectMake(0, separatorViewY+ACSeparatorViewHeight, ACScreenWidth, ACButtonHeight+ACSafeAreaHeight); 221 | 222 | cancelButton.tag = _otherButtonTitles.count; 223 | [cancelButton setTitle:_cancelButtonTitle forState:UIControlStateNormal]; 224 | cancelButton.backgroundColor = [UIColor whiteColor]; 225 | cancelButton.titleLabel.font = ACButtonTitleFont; 226 | [cancelButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 227 | UIImage *image = [UIImage imageWithContentsOfFile:[[self _acBundle] pathForResource:@"actionSheetHighLighted@2x" ofType:@"png"]]; 228 | [cancelButton setBackgroundImage:image forState:UIControlStateHighlighted]; 229 | 230 | [cancelButton addTarget:self action:@selector(_didClickButton:) forControlEvents:UIControlEventTouchUpInside]; 231 | [_buttonBackgroundView addSubview:cancelButton]; 232 | 233 | [cancelButton setTitleEdgeInsets:UIEdgeInsetsMake(-ACSafeAreaHeight, 0, 0, 0)]; 234 | 235 | /// 最后计算 所有按钮父视图的frame 236 | CGFloat height = titleLabelHeight + ACButtonHeight * showListCount + ACSeparatorViewHeight + cancelButton.frame.size.height; 237 | _buttonBackgroundView.frame = CGRectMake(0, ACScreenHeight, ACScreenWidth, height); 238 | } 239 | 240 | 241 | #pragma mark - Public Methods 242 | 243 | - (void)show { 244 | 245 | UIWindow *window = [UIApplication sharedApplication].keyWindow; 246 | [window addSubview:self]; 247 | self.hidden = NO; 248 | 249 | ACWeakSelf; 250 | [UIView animateWithDuration:ACShowAnimateDuration 251 | delay:0 252 | usingSpringWithDamping:1 253 | initialSpringVelocity:10 254 | options:UIViewAnimationOptionLayoutSubviews 255 | animations:^{ 256 | weakSelf.darkShadowView.alpha = ACDarkShadowViewAlpha; 257 | weakSelf.buttonBackgroundView.transform = CGAffineTransformMakeTranslation(0, -weakSelf.buttonBackgroundView.frame.size.height); 258 | } completion:^(BOOL finished) { 259 | 260 | }]; 261 | } 262 | 263 | 264 | #pragma mark - Private methods 265 | /// 点击按钮 266 | - (void)_didClickButton:(UIButton *)button { 267 | 268 | if (_delegate && [_delegate respondsToSelector:@selector(actionSheet:didClickedButtonAtIndex:)]) { 269 | [_delegate actionSheet:self didClickedButtonAtIndex:button.tag]; 270 | } 271 | 272 | if (self.actionSheetBlock) { 273 | self.actionSheetBlock(button.tag); 274 | } 275 | 276 | [self _hide]; 277 | } 278 | 279 | - (void)_dismissViewAction:(UITapGestureRecognizer *)tap { 280 | 281 | if (_delegate && [_delegate respondsToSelector:@selector(actionSheet:didClickedButtonAtIndex:)]) { 282 | [_delegate actionSheet:self didClickedButtonAtIndex:_otherButtonTitles.count]; 283 | } 284 | 285 | if (self.actionSheetBlock) { 286 | self.actionSheetBlock(_otherButtonTitles.count); 287 | } 288 | 289 | [self _hide]; 290 | } 291 | 292 | - (void)_hide { 293 | 294 | ACWeakSelf; 295 | [UIView animateWithDuration:ACHideAnimateDuration animations:^{ 296 | weakSelf.darkShadowView.alpha = 0; 297 | weakSelf.buttonBackgroundView.transform = CGAffineTransformIdentity; 298 | } completion:^(BOOL finished) { 299 | weakSelf.hidden = YES; 300 | [weakSelf removeFromSuperview]; 301 | }]; 302 | } 303 | 304 | 305 | - (NSBundle *)_acBundle { 306 | 307 | NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[ACActionSheet class]] pathForResource:@"ACActionSheet" ofType:@"bundle"]]; 308 | 309 | return bundle; 310 | } 311 | 312 | #pragma mark - Getters Setters 313 | - (UIScrollView *)scrollView { 314 | if (!_scrollView) { 315 | _scrollView = UIScrollView.alloc.init; 316 | _scrollView.alwaysBounceVertical = YES; 317 | _scrollView.showsHorizontalScrollIndicator = NO; 318 | _scrollView.backgroundColor = UIColor.whiteColor; 319 | 320 | } 321 | return _scrollView; 322 | } 323 | @end 324 | -------------------------------------------------------------------------------- /ACActionSheet/ACAlertView/UIAlertController+ACAlertView.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+ACAlertView.h 3 | // ACActionSheetDemo 4 | // 5 | // Created by zhangziyun 6 | 7 | // GitHub: https://github.com/GardenerYun 8 | // Email: gardeneryun@foxmail.com 9 | // 简书博客地址: http://www.jianshu.com/users/8489e70e237d/latest_articles 10 | // 如有问题或建议请联系我,我会马上解决问题~ (ง •̀_•́)ง 11 | 12 | // Copyright (C) 2016 by 章子云 13 | // 14 | // Permission is hereby granted, free of charge, to any 15 | // person obtaining a copy of this software and 16 | // associated documentation files (the "Software"), to 17 | // deal in the Software without restriction, including 18 | // without limitation the rights to use, copy, modify, merge, 19 | // publish, distribute, sublicense, and/or sell copies of the 20 | // Software, and to permit persons to whom the Software is 21 | // furnished to do so, subject to the following conditions: 22 | // 23 | // The above copyright notice and this permission notice shall 24 | // be included in all copies or substantial portions of the Software. 25 | // 26 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 28 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 30 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 31 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | 34 | #import 35 | 36 | NS_ASSUME_NONNULL_BEGIN 37 | 38 | typedef void(^ACAlertViewBlock)(NSInteger buttonIndex); 39 | 40 | @interface UIAlertController (ACAlertView) 41 | 42 | 43 | 44 | 45 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title 46 | message:(nullable NSString *)message 47 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 48 | confirmButtonTitle:(nullable NSString *)confirmButtonTitle 49 | preferredStyle:(UIAlertControllerStyle)preferredStyle 50 | alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock; 51 | 52 | 53 | 54 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title 55 | message:(nullable NSString *)message 56 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 57 | confirmButtonTitle:(nullable NSString *)confirmButtonTitle 58 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 59 | preferredStyle:(UIAlertControllerStyle)preferredStyle 60 | alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock; 61 | 62 | 63 | 64 | - (void)show; 65 | 66 | - (void)showWithAnimated:(BOOL)animated completion:(void (^ __nullable)(void))completion; 67 | 68 | 69 | @end 70 | 71 | NS_ASSUME_NONNULL_END 72 | -------------------------------------------------------------------------------- /ACActionSheet/ACAlertView/UIAlertController+ACAlertView.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+ACAlertView.m 3 | // ACActionSheetDemo 4 | // 5 | // Created by zhangziyun 6 | 7 | // GitHub: https://github.com/GardenerYun 8 | // Email: gardeneryun@foxmail.com 9 | // 简书博客地址: http://www.jianshu.com/users/8489e70e237d/latest_articles 10 | // 如有问题或建议请联系我,我会马上解决问题~ (ง •̀_•́)ง 11 | 12 | // Copyright (C) 2016 by 章子云 13 | // 14 | // Permission is hereby granted, free of charge, to any 15 | // person obtaining a copy of this software and 16 | // associated documentation files (the "Software"), to 17 | // deal in the Software without restriction, including 18 | // without limitation the rights to use, copy, modify, merge, 19 | // publish, distribute, sublicense, and/or sell copies of the 20 | // Software, and to permit persons to whom the Software is 21 | // furnished to do so, subject to the following conditions: 22 | // 23 | // The above copyright notice and this permission notice shall 24 | // be included in all copies or substantial portions of the Software. 25 | // 26 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 28 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 30 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 31 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | 34 | 35 | #import "UIAlertController+ACAlertView.h" 36 | 37 | @implementation UIAlertController (ACAlertView) 38 | 39 | #pragma mark - init/create methods 40 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title 41 | message:(nullable NSString *)message 42 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 43 | confirmButtonTitle:(nullable NSString *)confirmButtonTitle 44 | preferredStyle:(UIAlertControllerStyle)preferredStyle 45 | alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock { 46 | 47 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title 48 | message:message 49 | cancelButtonTitle:cancelButtonTitle 50 | confirmButtonTitle:confirmButtonTitle 51 | otherButtonTitles:nil 52 | preferredStyle:preferredStyle 53 | alertViewBlock:alertViewBlock]; 54 | 55 | return alertController; 56 | } 57 | 58 | 59 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title 60 | message:(nullable NSString *)message 61 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 62 | confirmButtonTitle:(nullable NSString *)confirmButtonTitle 63 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 64 | preferredStyle:(UIAlertControllerStyle)preferredStyle 65 | alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock { 66 | 67 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:preferredStyle]; 68 | 69 | NSMutableArray *titles = [NSMutableArray array]; 70 | 71 | if (cancelButtonTitle.length > 0) { 72 | [titles addObject:cancelButtonTitle]; 73 | } 74 | 75 | if (confirmButtonTitle.length > 0) { 76 | [titles addObject:confirmButtonTitle]; 77 | } 78 | 79 | if (otherButtonTitles.count > 0) { 80 | [titles addObjectsFromArray:otherButtonTitles]; 81 | } 82 | 83 | for (NSInteger i=0; i 0) { 136 | currentViewController = currentViewController.childViewControllers.lastObject; 137 | return currentViewController; 138 | } else { 139 | return currentViewController; 140 | } 141 | } 142 | 143 | } 144 | } 145 | @end 146 | -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5A866BB423A0BFF600615566 /* UIAlertController+ACAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A866BB223A0BFF600615566 /* UIAlertController+ACAlertView.m */; }; 11 | 5AE026B4239E2E3400C853A1 /* ACActionSheet.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 5AE026AF239E2E3400C853A1 /* ACActionSheet.bundle */; }; 12 | 5AE026B5239E2E3400C853A1 /* ACActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AE026B0239E2E3400C853A1 /* ACActionSheet.m */; }; 13 | 5C3538921CD8737300731917 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C35388B1CD8737300731917 /* AppDelegate.m */; }; 14 | 5C3538931CD8737300731917 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5C35388C1CD8737300731917 /* Assets.xcassets */; }; 15 | 5C3538961CD8737300731917 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C35388F1CD8737300731917 /* main.m */; }; 16 | 5C3538971CD8737300731917 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C3538911CD8737300731917 /* ViewController.m */; }; 17 | 5C35389C1CD8743F00731917 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5C3538981CD8743F00731917 /* LaunchScreen.storyboard */; }; 18 | 5C35389D1CD8743F00731917 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5C35389A1CD8743F00731917 /* Main.storyboard */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 5A866BB223A0BFF600615566 /* UIAlertController+ACAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertController+ACAlertView.m"; sourceTree = ""; }; 23 | 5A866BB323A0BFF600615566 /* UIAlertController+ACAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAlertController+ACAlertView.h"; sourceTree = ""; }; 24 | 5AE026AE239E2E3400C853A1 /* ACActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACActionSheet.h; sourceTree = ""; }; 25 | 5AE026AF239E2E3400C853A1 /* ACActionSheet.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ACActionSheet.bundle; sourceTree = ""; }; 26 | 5AE026B0239E2E3400C853A1 /* ACActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACActionSheet.m; sourceTree = ""; }; 27 | 5C3538701CD844B900731917 /* ACActionSheetDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ACActionSheetDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 5C35388A1CD8737300731917 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ACActionSheetDemo/AppDelegate.h; sourceTree = SOURCE_ROOT; }; 29 | 5C35388B1CD8737300731917 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = ACActionSheetDemo/AppDelegate.m; sourceTree = SOURCE_ROOT; }; 30 | 5C35388C1CD8737300731917 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ACActionSheetDemo/Assets.xcassets; sourceTree = SOURCE_ROOT; }; 31 | 5C35388E1CD8737300731917 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ACActionSheetDemo/Info.plist; sourceTree = SOURCE_ROOT; }; 32 | 5C35388F1CD8737300731917 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ACActionSheetDemo/main.m; sourceTree = SOURCE_ROOT; }; 33 | 5C3538901CD8737300731917 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewController.h; path = ACActionSheetDemo/ViewController.h; sourceTree = SOURCE_ROOT; }; 34 | 5C3538911CD8737300731917 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ViewController.m; path = ACActionSheetDemo/ViewController.m; sourceTree = SOURCE_ROOT; }; 35 | 5C3538991CD8743F00731917 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = ACActionSheetDemo/Base.lproj/LaunchScreen.storyboard; sourceTree = SOURCE_ROOT; }; 36 | 5C35389B1CD8743F00731917 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = ACActionSheetDemo/Base.lproj/Main.storyboard; sourceTree = SOURCE_ROOT; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | 5C35386D1CD844B900731917 /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | 5A866BB123A0BFF600615566 /* ACAlertView */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 5A866BB323A0BFF600615566 /* UIAlertController+ACAlertView.h */, 54 | 5A866BB223A0BFF600615566 /* UIAlertController+ACAlertView.m */, 55 | ); 56 | path = ACAlertView; 57 | sourceTree = ""; 58 | }; 59 | 5AE026AD239E2E3400C853A1 /* ACActionSheet */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 5AE026AE239E2E3400C853A1 /* ACActionSheet.h */, 63 | 5AE026B0239E2E3400C853A1 /* ACActionSheet.m */, 64 | 5AE026AF239E2E3400C853A1 /* ACActionSheet.bundle */, 65 | 5A866BB123A0BFF600615566 /* ACAlertView */, 66 | ); 67 | path = ACActionSheet; 68 | sourceTree = ""; 69 | }; 70 | 5C3538671CD844B900731917 = { 71 | isa = PBXGroup; 72 | children = ( 73 | 5AE026AD239E2E3400C853A1 /* ACActionSheet */, 74 | 5C3538721CD844B900731917 /* ACActionSheetDemo */, 75 | 5C3538711CD844B900731917 /* Products */, 76 | ); 77 | sourceTree = ""; 78 | }; 79 | 5C3538711CD844B900731917 /* Products */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 5C3538701CD844B900731917 /* ACActionSheetDemo.app */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | 5C3538721CD844B900731917 /* ACActionSheetDemo */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 5C35388A1CD8737300731917 /* AppDelegate.h */, 91 | 5C35388B1CD8737300731917 /* AppDelegate.m */, 92 | 5C3538901CD8737300731917 /* ViewController.h */, 93 | 5C3538911CD8737300731917 /* ViewController.m */, 94 | 5C35389A1CD8743F00731917 /* Main.storyboard */, 95 | 5C35388C1CD8737300731917 /* Assets.xcassets */, 96 | 5C3538981CD8743F00731917 /* LaunchScreen.storyboard */, 97 | 5C3538731CD844B900731917 /* Supporting Files */, 98 | ); 99 | name = ACActionSheetDemo; 100 | path = ACActionSheet; 101 | sourceTree = ""; 102 | }; 103 | 5C3538731CD844B900731917 /* Supporting Files */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 5C35388E1CD8737300731917 /* Info.plist */, 107 | 5C35388F1CD8737300731917 /* main.m */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | /* End PBXGroup section */ 113 | 114 | /* Begin PBXNativeTarget section */ 115 | 5C35386F1CD844B900731917 /* ACActionSheetDemo */ = { 116 | isa = PBXNativeTarget; 117 | buildConfigurationList = 5C3538871CD844B900731917 /* Build configuration list for PBXNativeTarget "ACActionSheetDemo" */; 118 | buildPhases = ( 119 | 5C35386C1CD844B900731917 /* Sources */, 120 | 5C35386D1CD844B900731917 /* Frameworks */, 121 | 5C35386E1CD844B900731917 /* Resources */, 122 | ); 123 | buildRules = ( 124 | ); 125 | dependencies = ( 126 | ); 127 | name = ACActionSheetDemo; 128 | productName = ACActionSheet; 129 | productReference = 5C3538701CD844B900731917 /* ACActionSheetDemo.app */; 130 | productType = "com.apple.product-type.application"; 131 | }; 132 | /* End PBXNativeTarget section */ 133 | 134 | /* Begin PBXProject section */ 135 | 5C3538681CD844B900731917 /* Project object */ = { 136 | isa = PBXProject; 137 | attributes = { 138 | LastUpgradeCheck = 0730; 139 | ORGANIZATIONNAME = "章子云"; 140 | TargetAttributes = { 141 | 5C35386F1CD844B900731917 = { 142 | CreatedOnToolsVersion = 7.3; 143 | DevelopmentTeam = 5NZRFH2HRF; 144 | ProvisioningStyle = Manual; 145 | }; 146 | }; 147 | }; 148 | buildConfigurationList = 5C35386B1CD844B900731917 /* Build configuration list for PBXProject "ACActionSheetDemo" */; 149 | compatibilityVersion = "Xcode 3.2"; 150 | developmentRegion = English; 151 | hasScannedForEncodings = 0; 152 | knownRegions = ( 153 | English, 154 | en, 155 | Base, 156 | ); 157 | mainGroup = 5C3538671CD844B900731917; 158 | productRefGroup = 5C3538711CD844B900731917 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | 5C35386F1CD844B900731917 /* ACActionSheetDemo */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | 5C35386E1CD844B900731917 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 5C35389D1CD8743F00731917 /* Main.storyboard in Resources */, 173 | 5C35389C1CD8743F00731917 /* LaunchScreen.storyboard in Resources */, 174 | 5C3538931CD8737300731917 /* Assets.xcassets in Resources */, 175 | 5AE026B4239E2E3400C853A1 /* ACActionSheet.bundle in Resources */, 176 | ); 177 | runOnlyForDeploymentPostprocessing = 0; 178 | }; 179 | /* End PBXResourcesBuildPhase section */ 180 | 181 | /* Begin PBXSourcesBuildPhase section */ 182 | 5C35386C1CD844B900731917 /* Sources */ = { 183 | isa = PBXSourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 5C3538971CD8737300731917 /* ViewController.m in Sources */, 187 | 5AE026B5239E2E3400C853A1 /* ACActionSheet.m in Sources */, 188 | 5A866BB423A0BFF600615566 /* UIAlertController+ACAlertView.m in Sources */, 189 | 5C3538961CD8737300731917 /* main.m in Sources */, 190 | 5C3538921CD8737300731917 /* AppDelegate.m in Sources */, 191 | ); 192 | runOnlyForDeploymentPostprocessing = 0; 193 | }; 194 | /* End PBXSourcesBuildPhase section */ 195 | 196 | /* Begin PBXVariantGroup section */ 197 | 5C3538981CD8743F00731917 /* LaunchScreen.storyboard */ = { 198 | isa = PBXVariantGroup; 199 | children = ( 200 | 5C3538991CD8743F00731917 /* Base */, 201 | ); 202 | name = LaunchScreen.storyboard; 203 | sourceTree = ""; 204 | }; 205 | 5C35389A1CD8743F00731917 /* Main.storyboard */ = { 206 | isa = PBXVariantGroup; 207 | children = ( 208 | 5C35389B1CD8743F00731917 /* Base */, 209 | ); 210 | name = Main.storyboard; 211 | sourceTree = ""; 212 | }; 213 | /* End PBXVariantGroup section */ 214 | 215 | /* Begin XCBuildConfiguration section */ 216 | 5C3538851CD844B900731917 /* Debug */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | ALWAYS_SEARCH_USER_PATHS = NO; 220 | CLANG_ANALYZER_NONNULL = YES; 221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 222 | CLANG_CXX_LIBRARY = "libc++"; 223 | CLANG_ENABLE_MODULES = YES; 224 | CLANG_ENABLE_OBJC_ARC = YES; 225 | CLANG_WARN_BOOL_CONVERSION = YES; 226 | CLANG_WARN_CONSTANT_CONVERSION = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_EMPTY_BODY = YES; 229 | CLANG_WARN_ENUM_CONVERSION = YES; 230 | CLANG_WARN_INT_CONVERSION = YES; 231 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 232 | CLANG_WARN_UNREACHABLE_CODE = YES; 233 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 234 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 235 | COPY_PHASE_STRIP = NO; 236 | DEBUG_INFORMATION_FORMAT = dwarf; 237 | ENABLE_STRICT_OBJC_MSGSEND = YES; 238 | ENABLE_TESTABILITY = YES; 239 | GCC_C_LANGUAGE_STANDARD = gnu99; 240 | GCC_DYNAMIC_NO_PIC = NO; 241 | GCC_NO_COMMON_BLOCKS = YES; 242 | GCC_OPTIMIZATION_LEVEL = 0; 243 | GCC_PREPROCESSOR_DEFINITIONS = ( 244 | "DEBUG=1", 245 | "$(inherited)", 246 | ); 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 254 | MTL_ENABLE_DEBUG_INFO = YES; 255 | ONLY_ACTIVE_ARCH = YES; 256 | SDKROOT = iphoneos; 257 | TARGETED_DEVICE_FAMILY = "1,2"; 258 | }; 259 | name = Debug; 260 | }; 261 | 5C3538861CD844B900731917 /* Release */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | ALWAYS_SEARCH_USER_PATHS = NO; 265 | CLANG_ANALYZER_NONNULL = YES; 266 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 267 | CLANG_CXX_LIBRARY = "libc++"; 268 | CLANG_ENABLE_MODULES = YES; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_WARN_BOOL_CONVERSION = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 280 | COPY_PHASE_STRIP = NO; 281 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 282 | ENABLE_NS_ASSERTIONS = NO; 283 | ENABLE_STRICT_OBJC_MSGSEND = YES; 284 | GCC_C_LANGUAGE_STANDARD = gnu99; 285 | GCC_NO_COMMON_BLOCKS = YES; 286 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 287 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 288 | GCC_WARN_UNDECLARED_SELECTOR = YES; 289 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 290 | GCC_WARN_UNUSED_FUNCTION = YES; 291 | GCC_WARN_UNUSED_VARIABLE = YES; 292 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 293 | MTL_ENABLE_DEBUG_INFO = NO; 294 | SDKROOT = iphoneos; 295 | TARGETED_DEVICE_FAMILY = "1,2"; 296 | VALIDATE_PRODUCT = YES; 297 | }; 298 | name = Release; 299 | }; 300 | 5C3538881CD844B900731917 /* Debug */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 304 | CODE_SIGN_STYLE = Manual; 305 | DEVELOPMENT_TEAM = 5NZRFH2HRF; 306 | INFOPLIST_FILE = ACActionSheetDemo/Info.plist; 307 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 308 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 309 | MARKETING_VERSION = 1.0.6; 310 | PRODUCT_BUNDLE_IDENTIFIER = AC.ACActionSheet; 311 | PRODUCT_NAME = "$(TARGET_NAME)"; 312 | PROVISIONING_PROFILE_SPECIFIER = "Wildcard Profile"; 313 | }; 314 | name = Debug; 315 | }; 316 | 5C3538891CD844B900731917 /* Release */ = { 317 | isa = XCBuildConfiguration; 318 | buildSettings = { 319 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 320 | CODE_SIGN_STYLE = Manual; 321 | DEVELOPMENT_TEAM = 5NZRFH2HRF; 322 | INFOPLIST_FILE = ACActionSheetDemo/Info.plist; 323 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 324 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 325 | MARKETING_VERSION = 1.0.6; 326 | PRODUCT_BUNDLE_IDENTIFIER = AC.ACActionSheet; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | PROVISIONING_PROFILE_SPECIFIER = "Wildcard Profile"; 329 | }; 330 | name = Release; 331 | }; 332 | /* End XCBuildConfiguration section */ 333 | 334 | /* Begin XCConfigurationList section */ 335 | 5C35386B1CD844B900731917 /* Build configuration list for PBXProject "ACActionSheetDemo" */ = { 336 | isa = XCConfigurationList; 337 | buildConfigurations = ( 338 | 5C3538851CD844B900731917 /* Debug */, 339 | 5C3538861CD844B900731917 /* Release */, 340 | ); 341 | defaultConfigurationIsVisible = 0; 342 | defaultConfigurationName = Release; 343 | }; 344 | 5C3538871CD844B900731917 /* Build configuration list for PBXNativeTarget "ACActionSheetDemo" */ = { 345 | isa = XCConfigurationList; 346 | buildConfigurations = ( 347 | 5C3538881CD844B900731917 /* Debug */, 348 | 5C3538891CD844B900731917 /* Release */, 349 | ); 350 | defaultConfigurationIsVisible = 0; 351 | defaultConfigurationName = Release; 352 | }; 353 | /* End XCConfigurationList section */ 354 | }; 355 | rootObject = 5C3538681CD844B900731917 /* Project object */; 356 | } 357 | -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/project.xcworkspace/xcuserdata/Acha.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GardenerYun/ACActionSheet/fe32e0ce876e6354f9a0461f2b26dfb21a137b81/ACActionSheetDemo.xcodeproj/project.xcworkspace/xcuserdata/Acha.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/xcuserdata/Acha.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/xcuserdata/Acha.xcuserdatad/xcschemes/ACActionSheetDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ACActionSheetDemo.xcodeproj/xcuserdata/Acha.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ACActionSheetDemo.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 5C35386F1CD844B900731917 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ACActionSheetDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ACActionSheet 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ACActionSheetDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ACActionSheet 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | 25 | } 26 | 27 | - (void)applicationDidEnterBackground:(UIApplication *)application { 28 | 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application { 32 | 33 | } 34 | 35 | - (void)applicationDidBecomeActive:(UIApplication *)application { 36 | 37 | } 38 | 39 | - (void)applicationWillTerminate:(UIApplication *)application { 40 | 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ACActionSheetDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /ACActionSheetDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ACActionSheetDemo/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "scale" : "3x" 10 | }, 11 | { 12 | "orientation" : "landscape", 13 | "idiom" : "iphone", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "8.0", 16 | "subtype" : "736h", 17 | "scale" : "3x" 18 | }, 19 | { 20 | "orientation" : "portrait", 21 | "idiom" : "iphone", 22 | "extent" : "full-screen", 23 | "minimum-system-version" : "8.0", 24 | "subtype" : "667h", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "orientation" : "portrait", 29 | "idiom" : "iphone", 30 | "extent" : "full-screen", 31 | "minimum-system-version" : "7.0", 32 | "scale" : "2x" 33 | }, 34 | { 35 | "orientation" : "portrait", 36 | "idiom" : "iphone", 37 | "extent" : "full-screen", 38 | "minimum-system-version" : "7.0", 39 | "subtype" : "retina4", 40 | "scale" : "2x" 41 | }, 42 | { 43 | "orientation" : "portrait", 44 | "idiom" : "ipad", 45 | "extent" : "full-screen", 46 | "minimum-system-version" : "7.0", 47 | "scale" : "1x" 48 | }, 49 | { 50 | "orientation" : "landscape", 51 | "idiom" : "ipad", 52 | "extent" : "full-screen", 53 | "minimum-system-version" : "7.0", 54 | "scale" : "1x" 55 | }, 56 | { 57 | "orientation" : "portrait", 58 | "idiom" : "ipad", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "orientation" : "landscape", 65 | "idiom" : "ipad", 66 | "extent" : "full-screen", 67 | "minimum-system-version" : "7.0", 68 | "scale" : "2x" 69 | }, 70 | { 71 | "orientation" : "portrait", 72 | "idiom" : "iphone", 73 | "extent" : "full-screen", 74 | "scale" : "1x" 75 | }, 76 | { 77 | "orientation" : "portrait", 78 | "idiom" : "iphone", 79 | "extent" : "full-screen", 80 | "scale" : "2x" 81 | }, 82 | { 83 | "orientation" : "portrait", 84 | "idiom" : "iphone", 85 | "extent" : "full-screen", 86 | "subtype" : "retina4", 87 | "scale" : "2x" 88 | }, 89 | { 90 | "orientation" : "portrait", 91 | "idiom" : "ipad", 92 | "extent" : "to-status-bar", 93 | "scale" : "1x" 94 | }, 95 | { 96 | "orientation" : "portrait", 97 | "idiom" : "ipad", 98 | "extent" : "full-screen", 99 | "scale" : "1x" 100 | }, 101 | { 102 | "orientation" : "landscape", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "landscape", 109 | "idiom" : "ipad", 110 | "extent" : "full-screen", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "orientation" : "portrait", 115 | "idiom" : "ipad", 116 | "extent" : "to-status-bar", 117 | "scale" : "2x" 118 | }, 119 | { 120 | "orientation" : "portrait", 121 | "idiom" : "ipad", 122 | "extent" : "full-screen", 123 | "scale" : "2x" 124 | }, 125 | { 126 | "orientation" : "landscape", 127 | "idiom" : "ipad", 128 | "extent" : "to-status-bar", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "orientation" : "landscape", 133 | "idiom" : "ipad", 134 | "extent" : "full-screen", 135 | "scale" : "2x" 136 | } 137 | ], 138 | "info" : { 139 | "version" : 1, 140 | "author" : "xcode" 141 | } 142 | } -------------------------------------------------------------------------------- /ACActionSheetDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ACActionSheetDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 51 | 61 | 71 | 81 | 91 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /ACActionSheetDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIRequiresFullScreen 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ACActionSheetDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ACActionSheet 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ACActionSheetDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ACActionSheet 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | 9 | 10 | #import "ViewController.h" 11 | #import "ACActionSheet.h" 12 | #import "UIAlertController+ACAlertView.h" 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | } 24 | 25 | /** 26 | * 系统 - UIActionSheet demo 27 | */ 28 | - (IBAction)_showUIActionSheet:(UIButton *)sender { 29 | 30 | UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"微信朋友圈" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"小视频" otherButtonTitles:@"拍照",@"从手机相册选择", nil]; 31 | 32 | [actionSheet showInView:self.view]; 33 | } 34 | 35 | /** 36 | * 系统 - UIAlertController demo 37 | */ 38 | - (IBAction)_showUIAlertController:(UIButton *)sender { 39 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"保存或删除数据" message:@"删除数据将不可恢复" preferredStyle: UIAlertControllerStyleActionSheet]; 40 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { 41 | NSLog(@"UIAlertController - 取消"); 42 | }]; 43 | UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { 44 | NSLog(@"UIAlertController - 删除"); 45 | }]; 46 | UIAlertAction *saveAction = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 47 | NSLog(@"UIAlertController - 保存"); 48 | }]; 49 | 50 | [alertController addAction:cancelAction]; 51 | [alertController addAction:deleteAction]; 52 | [alertController addAction:saveAction]; 53 | 54 | [self presentViewController:alertController animated:YES completion:nil]; 55 | } 56 | 57 | 58 | /** 59 | * ACActionSheet type delegate demo 60 | */ 61 | - (IBAction)_showACActionSheetTypeDelegate:(UIButton *)sender { 62 | 63 | ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:@"保存或删除数据" 64 | delegate:self 65 | cancelButtonTitle:@"取消" 66 | destructiveButtonTitle:@"删除" 67 | otherButtonTitles:@"保存",@"更改",@"按钮3",@"按钮4",@"按钮5",@"按钮6",@"按钮7",@"按钮8",@"按钮9",@"按钮10",@"按钮11",@"按钮12", nil]; 68 | 69 | [actionSheet show]; 70 | } 71 | 72 | 73 | 74 | /** 75 | * ACActionSheet type block demo 76 | */ 77 | - (IBAction)_showACActionSheetTypeBlock:(UIButton *)sender { 78 | ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:nil 79 | cancelButtonTitle:@"取消" 80 | destructiveButtonTitle:nil 81 | otherButtonTitles:@[@"小视频",@"拍照",@"从手机相册选择"] 82 | actionSheetBlock:^(NSInteger buttonIndex) { 83 | NSLog(@"ACActionSheet block - %ld",buttonIndex); 84 | }]; 85 | [actionSheet show]; 86 | } 87 | 88 | - (IBAction)_showUIAlertControllerAction:(id)sender { 89 | 90 | [[UIAlertController alertControllerWithTitle:@"提示" 91 | message:@"保持或者删除数据" 92 | cancelButtonTitle:@"取消" 93 | confirmButtonTitle:@"确定" 94 | preferredStyle:UIAlertControllerStyleAlert 95 | alertViewBlock:^(NSInteger buttonIndex) { 96 | NSLog(@"UIAlertController 类目 - %@",@(buttonIndex)); 97 | }] show] ; 98 | 99 | } 100 | 101 | 102 | - (IBAction)_showUIAlertControllerMoreButtonAction:(id)sender { 103 | 104 | [[UIAlertController alertControllerWithTitle:@"提示" 105 | message:@"保持或者删除数据" 106 | cancelButtonTitle:@"取消" 107 | confirmButtonTitle:@"确定" 108 | otherButtonTitles:@[@"按钮3",@"按钮4",@"按钮5",@"按钮6",@"按钮7",@"按钮8",@"按钮9",@"按钮10",@"按钮11",@"按钮12",@"按钮13",@"按钮14"] 109 | preferredStyle:UIAlertControllerStyleActionSheet 110 | alertViewBlock:^(NSInteger buttonIndex) { 111 | NSLog(@"UIAlertController 类目 - %@",@(buttonIndex)); 112 | }] show] ; 113 | 114 | } 115 | 116 | 117 | #pragma mark - UIActionSheet delegate 118 | 119 | - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 120 | NSLog(@"UIActionSheet - %@ %ld",[actionSheet buttonTitleAtIndex:buttonIndex],buttonIndex); 121 | } 122 | 123 | #pragma mark - ACActionSheet delegate 124 | - (void)actionSheet:(ACActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex { 125 | NSLog(@"ACActionSheet delegate - %ld",buttonIndex); 126 | } 127 | 128 | 129 | - (void)didReceiveMemoryWarning { 130 | [super didReceiveMemoryWarning]; 131 | // Dispose of any resources that can be recreated. 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /ACActionSheetDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ACActionSheet 4 | // 5 | // Created by Zhangziyun on 16/5/3. 6 | // Copyright © 2016年 章子云. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 章子云(ZHANGZIYUN) (https://github.com/GardenerYun) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # [ACActionSheet][1] - 一个简洁好用的ActionSheet/AlertView 4 | 5 | [![GitHub license](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/GardenerYun/ACActionSheet/master/LICENSE) 6 | ![podversion](https://img.shields.io/cocoapods/v/ACActionSheet.svg) 7 | [![CocoaPods](http://img.shields.io/cocoapods/p/ACActionSheet.svg?style=flat)](http://cocoadocs.org/docsets/ACActionSheet) 8 | [![Support](https://img.shields.io/badge/support-iOS8+-blue.svg?style=flat)](https://www.apple.com/nl/ios/) 9 | 10 | 11 | ### **系统UIActionSheet其实挺好用的。但是有时候系统的风格跟APP有些不搭。而且在iOS8.0 UIKit更新了UIAlertController,苹果建议:*UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead*。** 12 | 13 | ### [ACActionSheet][1]是仿微信效果的,简洁清新,方便好用 14 | 15 | > GitHub: https://github.com/GardenerYun 16 | 17 | > Email: gardeneryun@foxmail.com 18 | 19 | > 简书博客地址: http://www.jianshu.com/users/8489e70e237d/latest_articles 20 | 21 | > 如有问题或建议请联系我,我会马上解决问题~ (ง •̀_•́)ง** 22 | 23 | ---------- 24 | ### 2022年01月04日 更新 (v1.0.6) 25 | 重写```ACActionSheet```工具。 26 | 1、使用UIScrollView,支持多按钮,可滑动。 27 | 2、重写show动画,更丝滑。 28 | 29 | ### 2019年12月11日 更新 (v1.0.5) 30 | 31 | 1.优化逻辑,并支持CocoaPods: ```pod 'ACActionSheet'``` 32 | 33 | 2.新增类目```UIAlertController+ACAlertView``` 34 | 为UIAlertController以UIAlertView(Deprecate)代码风格新增block初始化方法,详情见代码: 35 | 36 | ``` 37 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title 38 | message:(nullable NSString *)message 39 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 40 | confirmButtonTitle:(nullable NSString *)confirmButtonTitle 41 | preferredStyle:(UIAlertControllerStyle)preferredStyle 42 | alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock; 43 | 44 | 45 | 46 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title 47 | message:(nullable NSString *)message 48 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 49 | confirmButtonTitle:(nullable NSString *)confirmButtonTitle 50 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 51 | preferredStyle:(UIAlertControllerStyle)preferredStyle 52 | alertViewBlock:(nullable ACAlertViewBlock)alertViewBlock; 53 | ``` 54 | 55 | 56 | 57 | ### (v1.0.0) 58 | 59 | - **这是微信效果截图** 60 | 61 | ![ACAcitonSheet_03](http://upload-images.jianshu.io/upload_images/1683760-a1efb2b8b5a0d07f.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![ACAcitonSheet_01](http://upload-images.jianshu.io/upload_images/1683760-0313142e01c4178e.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![ACAcitonSheet_02](http://upload-images.jianshu.io/upload_images/1683760-38bd04509523d024.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 62 | 63 | 64 | ---------- 65 | 66 | 67 | - **系统UIActionSheet (UIAlertController)gif 效果图** 68 | 69 | ![系统ActionSheet.gif](http://ww1.sinaimg.cn/large/a0a8dcc1gw1f3oyd5kd9kg208w0fsqcd.gif) 70 | 71 | ---------- 72 | 73 | - **ACActionSheet gif 效果图** 74 | 75 | ![ACActionSheet.gif](http://ww4.sinaimg.cn/large/a0a8dcc1gw1f3oydmolofg208w0fs7aj.gif) 76 | 77 | ---------- 78 | 79 | ## 代码示例 80 | **[ACActionSheet][1]尽力按照苹果UIKit代码风格编写。initWith...创建 -> show方法 -> delegate或block监听事件** 81 | 82 | - **delegate模式 创建** 83 | 84 | ``` 85 | /** 86 | * type delegate 87 | * 88 | * @param title title (可以为空) 89 | * @param delegate delegate 90 | * @param cancelButtonTitle "取消"按钮 (默认有) 91 | * @param destructiveButtonTitle "警示性"(红字)按钮 (可以为空) 92 | * @param otherButtonTitles otherButtonTitles 93 | */ 94 | - (instancetype)initWithTitle:(NSString *)title 95 | delegate:(id)delegate 96 | cancelButtonTitle:(NSString *)cancelButtonTitle 97 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 98 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 99 | 100 | /***********************************************************************************/ 101 | 102 | ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:@"保存或删除数据" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"删除" otherButtonTitles:@"保存",@"更改", nil]; 103 | 104 | [actionSheet show]; 105 | 106 | #pragma mark - ACActionSheet delegate 107 | - (void)actionSheet:(ACActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex { 108 | NSLog(@"ACActionSheet delegate - %ld",buttonIndex); 109 | } 110 | ``` 111 | 112 | - **block模式 创建** 113 | 114 | ``` 115 | typedef void(^ACActionSheetBlock)(NSInteger buttonIndex); 116 | 117 | /** 118 | * type block 119 | * 120 | * @param title title (可以为空) 121 | * @param cancelButtonTitle "取消"按钮 (默认有) 122 | * @param destructiveButtonTitle "警示性"(红字)按钮 (可以为空) 123 | * @param otherButtonTitles otherButtonTitles 124 | * @param actionSheetBlock actionSheetBlock 125 | */ 126 | - (instancetype)initWithTitle:(NSString *)title 127 | cancelButtonTitle:(NSString *)cancelButtonTitle 128 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 129 | otherButtonTitles:(NSArray *)otherButtonTitles 130 | actionSheetBlock:(ACActionSheetBlock) actionSheetBlock; 131 | 132 | 133 | /***********************************************************************************/ 134 | ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@[@"小视频",@"拍照",@"从手机相册选择"] actionSheetBlock:^(NSInteger buttonIndex) { 135 | NSLog(@"ACActionSheet block - %ld",buttonIndex); 136 | }]; 137 | [actionSheet show]; 138 | ``` 139 | 140 | 141 | [1]: https://github.com/GardenerYun/ACActionSheet 142 | 143 | --------------------------------------------------------------------------------