This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NAAlertView.h
167 lines (123 loc) · 5.16 KB
/
NAAlertView.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//
// NAAlertView.h
// NAAlertView
//
// Created by Jonathan Hooper on 7/26/13.
// Copyright (c) 2013 NewAperio LLC. All rights reserved.
//
typedef NS_ENUM(NSInteger, NAAlertViewButtonType){
NAAlertViewButtonTypeRegular = 0,
NAAlertViewButtonTypeCancel = 1
};
#import <UIKit/UIKit.h>
@interface NAAlertView : UIView
/**
The background color for the alert view. The default is white.
*/
@property (nonatomic, strong) UIColor *backgroundColor;
/**
The border color for the alert view. Also the border color for the button borders and the color for text. The default is grey.
*/
@property (nonatomic, strong) UIColor *borderColor;
/**
The font used for the text in the alert view.
*/
@property (nonatomic, strong) UIFont *font;
/**
The title to display at the top of the alert view. This is required for the view to display.
*/
@property (nonatomic, strong) NSString *title;
/**
The alert view's message. This is required for the view to display.
*/
@property (nonatomic, strong) NSString *message;
/**
The image to be displayed by the alert view. This is not required to display the view.
*/
@property (nonatomic, strong) UIImage *image;
/**
Changes the default background color for all alert views generated
@param color The new default background color
*/
+ (void)setDefaultBackgroundColor:(UIColor *)color;
/**
Changes the default border color for all alert view generated
@param color The new default border color
*/
+ (void)setDefaultBorderColor:(UIColor *)color;
/**
Sets the default font for all alert views generated
@param font The new default font
*/
+ (void)setDefaultFont:(UIFont *)font;
/**
Returns an empty NAAlertView object with just a greyed out background.
The view generated by this method is not ready to be displayed. An alert view will not be displayed without at least a title and a message.
@return A NAAlertView with just a greyed out background. This method does not draw the alert box.
*/
- (id)init;
/**
Returns an empty NAAlertView object with just a greyed out background.
This method just calls init. The frame provided is ignored since the view occupies the entire screen.
The view generated by this method is not ready to be displayed. An alert view will not be displayed without at least a title and a message.
@return A NAAlertView with just a greyed out background. This method does not draw the alert box.
@see -init
*/
- (id)initWithFrame:(CGRect)frame;
/**
Returns a NAAlertView with a title and message.
@param title The title to be displayed by the alert view
@param message The message to be displayed by the alert view
@return A NAAlertView that is ready to be displayed with a title and message
*/
- (id)initWithTitle:(NSString *)title message:(NSString *)message;
/**
Returns a NAAlertView with a title, message, and image.
@param title The title to be displayed by the alert view
@param message The message to be displayed by the alert view
@param imagePath The image path of the image to be displayed by the alert view
@return A NAAlertView that is ready to be displayed with a title, message, and image
*/
- (id)initWithTitle:(NSString *)title message:(NSString *)message imagePath:(NSString *)imagePath;
/**
Returns a NAAlertView with a title, message, and image.
@param title The title to be displayed by the alert view
@param message The message to be displayed by the alert view
@param imageName The name of the image in the main bundle to be displayed by the alert view
@return A NAAlertView that is ready to be displayed with a title, message, and image
*/
- (id)initWithTitle:(NSString *)title message:(NSString *)message imageNamed:(NSString *)imageName;
/**
Returns a NAAlertView with a title, message, and image.
@param title The title to be displayed by the alert view
@param message The message to be displayed by the alert view
@param image The image to be displayed by the alert view
@return A NAAlertView that is ready to be displayed with a title, message, and image
*/
- (id)initWithTitle:(NSString *)title message:(NSString *)message image:(UIImage *)image;
/**
Adds a button to the alert view
An alert view can only have two buttons. A cancel button and another tpye of button. Adding a button of type other than a `NAAlertViewButtonTypeCancel` will result in the existing button being overwritten.
A regular button will be added on the left and and a cancel button will be added on the right.
@param title The button's title
@param block The block to be executed when the button is pressed
@param buttonType The type of button to be selected
@see NAAlertViewButtonType
*/
- (void)addButtonWithTitle:(NSString *)title block:(void (^)())block type:(NAAlertViewButtonType)buttonType;
/**
Removes a button from the alert view
@param buttonType The type of button that you wish to remove
*/
- (void)removeButtonWithType:(NAAlertViewButtonType)buttonType;
/**
Displayes the alert view over the current view controller
@param If yes, animates the appearance, otherwise does not.
*/
- (void)showAnimated:(BOOL)animated;
/**
Removes the alert view from the current view controller
@param If yes, animates the dismissal, otherwise does not.
*/
- (void)dismissAnimated:(BOOL)animated;
@end