-
Notifications
You must be signed in to change notification settings - Fork 8
/
CNPPopupController.h
executable file
·126 lines (93 loc) · 4.86 KB
/
CNPPopupController.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
// 弹出菜单(用来显示登录消息,有下面,中间,全频三种方式)的申明
//
// CNPPopupController.h
// CNPPopupController
//
//
// Copyright (c) 2015 Jackson.
//
#import <UIKit/UIKit.h>
#import "SRMonthPicker.h"
@protocol CNPPopupControllerDelegate;
@class CNPPopupTheme, CNPPopupButtonItem;
@interface CNPPopupController : NSObject{
/**
* 标题
*/
UILabel *title1;
UIDatePicker *datepicker;
SRMonthPicker *pickMonth;
}
@property int flag;
@property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) NSAttributedString *popupTitle;
@property (nonatomic, strong) NSArray *contents;
@property (nonatomic, strong) NSArray *buttonItems;
@property (nonatomic, strong) CNPPopupButtonItem *destructiveButtonItem;
@property (nonatomic, strong) CNPPopupTheme *theme;
@property (nonatomic, weak) id <CNPPopupControllerDelegate> delegate;
- (instancetype)initWithTitle:(NSString*)text
flag:(int)flag
buttonItems:(NSArray *)buttonItems
destructiveButtonItem:(CNPPopupButtonItem *)destructiveButtonItem;
- (instancetype)initWithTitle:(NSAttributedString *)popupTitle
contents:(NSArray *)contents
buttonItems:(NSArray *)buttonItems
destructiveButtonItem:(CNPPopupButtonItem *)destructiveButtonItem;
- (void)presentPopupControllerAnimated:(BOOL)flag;
- (void)dismissPopupControllerAnimated:(BOOL)flag;
@end
@protocol CNPPopupControllerDelegate <NSObject>
@optional
-(void)didSelect:(NSString*)timestring;
-(void)didSelect1:(NSString *)timestring;
-(void)didSelect2:(NSString *)timestring;
- (void)popupControllerWillPresent:(CNPPopupController *)controller;
- (void)popupControllerDidPresent:(CNPPopupController *)controller;
- (void)popupController:(CNPPopupController *)controller willDismissWithButtonTitle:(NSString *)title;
- (void)popupController:(CNPPopupController *)controller didDismissWithButtonTitle:(NSString *)title;
@end
// CNPPopupStyle: Controls how the popup looks once presented
typedef NS_ENUM(NSUInteger, CNPPopupStyle) {
CNPPopupStyleActionSheet = 0, // Displays the popup similar to an action sheet from the bottom.
CNPPopupStyleCentered, // Displays the popup in the center of the screen.
CNPPopupStyleFullscreen // Displays the popup similar to a fullscreen viewcontroller.
};
// CNPPopupPresentationStyle: Controls how the popup is presented
typedef NS_ENUM(NSInteger, CNPPopupPresentationStyle) {
CNPPopupPresentationStyleFadeIn = 0,
CNPPopupPresentationStyleSlideInFromTop,
CNPPopupPresentationStyleSlideInFromBottom,
CNPPopupPresentationStyleSlideInFromLeft,
CNPPopupPresentationStyleSlideInFromRight
};
// CNPPopupMaskType
typedef NS_ENUM(NSInteger, CNPPopupMaskType) {
CNPPopupMaskTypeNone = 0, // Allow interaction with underlying views.
CNPPopupMaskTypeClear, // Don't allow interaction with underlying views.
CNPPopupMaskTypeDimmed, // Don't allow interaction with underlying views, dim background.
};
typedef void(^SelectionHandler) (CNPPopupButtonItem *item);
@interface CNPPopupButtonItem : NSObject
@property (nonatomic, strong) NSAttributedString *buttonTitle;
@property (nonatomic, strong) UIColor *backgroundColor;
@property (nonatomic, strong) UIColor *borderColor;
@property (nonatomic, assign) CGFloat borderWidth;
@property (nonatomic, assign) CGFloat cornerRadius;
@property (nonatomic, assign) CGFloat buttonHeight;
@property (nonatomic, strong) SelectionHandler selectionHandler;
+ (CNPPopupButtonItem *)defaultButtonItemWithTitle:(NSAttributedString *)title backgroundColor:(UIColor *)color;
@end
@interface CNPPopupTheme : NSObject
@property (nonatomic, strong) UIColor *backgroundColor; // Background color of the popup content view (Default white)
@property (nonatomic, assign) CGFloat cornerRadius; // Corner radius of the popup content view (Default 6.0)
@property (nonatomic, assign) UIEdgeInsets popupContentInsets; // Inset of labels, images and buttons on the popup content view (Default 16.0 on all sides)
@property (nonatomic, assign) CNPPopupStyle popupStyle; // How the popup looks once presented (Default centered)
@property (nonatomic, assign) CNPPopupPresentationStyle presentationStyle; // How the popup is presented (Defauly slide in from bottom)
@property (nonatomic, assign) BOOL dismissesOppositeDirection; // If presented from a direction, should it dismiss in the opposite? (Defaults to NO. i.e. Goes back the way it came in)
@property (nonatomic, assign) CNPPopupMaskType maskType; // Backgound mask of the popup (Default dimmed)
@property (nonatomic, assign) BOOL shouldDismissOnBackgroundTouch; // Popup should dismiss on tapping on background mask (Default yes)
@property (nonatomic, assign) CGFloat contentVerticalPadding; // Spacing between each vertical element (Default 12.0)
// Factory method to help build a default theme
+ (CNPPopupTheme *)defaultTheme;
@end