由于项目设计ActionSheet的颜色是橘色,而系统自带的 UIActionSheet 或 UIAlertController 都是只有蓝色或红色,在ios8之后,重写willPresentActionSheet方法时actionSheet.subviews时里没有东西,所以只能自己自定义一个UIView
1. JoopicActionSheet.h
//
// JoopicActionSheet.h
// joopic
//
// Created by jianxiong li on 16/1/14.
// Copyright © 2016年 joobot. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol JoopicActionSheetDelegate <NSObject>
-(void)didSelectIndex : (NSInteger) index;
@end
@interface JoopicActionSheet : UIView
@property (nonatomic , strong) id<JoopicActionSheetDelegate> delegate;
-(id)initWithList : (NSArray *)list title : (NSString *) title;
-(void) showInView : (UIViewController *)controller;
@end
2.JoopicActionSheet.m
//
// JoopicActionSheet.m
// joopic
//
// Created by jianxiong li on 16/1/14.
// Copyright © 2016年 joobot. All rights reserved.
//
#import "JoopicActionSheet.h"
#define RGBCOLOR(r, g, b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r, g, b, a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
//获取设备的物理高度
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
//获取设备的物理宽度
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define JoopicActionSheetItemHeight 57
@interface JoopicActionSheet ()<UITableViewDataSource , UITableViewDelegate , UIGestureRecognizerDelegate>
@property (nonatomic , strong) UITableView *tableview;
@property (nonatomic , strong) NSArray *listData;
@property (nonatomic , strong) NSString * title;
@property (nonatomic ,