File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,14 @@ typedef enum {
31
31
message : (NSString *)message
32
32
duration : (NSTimeInterval )duration ;
33
33
34
+ + (void )showInViewController : (UIViewController*)viewController
35
+ tintColor : (UIColor*)tintColor
36
+ font : (UIFont*)font
37
+ textAlignment : (NSTextAlignment )textAlignment
38
+ image : (UIImage*)image
39
+ message : (NSString *)message
40
+ duration : (NSTimeInterval )duration ;
41
+
34
42
#pragma mark + creators
35
43
36
44
+ (CSNotificationView*)notificationViewWithParentViewController : (UIViewController*)viewController
Original file line number Diff line number Diff line change @@ -58,6 +58,34 @@ + (void)showInViewController:(UIViewController*)viewController
58
58
59
59
}
60
60
61
+ + (void )showInViewController : (UIViewController*)viewController
62
+ tintColor : (UIColor*)tintColor
63
+ font : (UIFont*)font
64
+ textAlignment : (NSTextAlignment )textAlignment
65
+ image : (UIImage*)image
66
+ message : (NSString *)message
67
+ duration : (NSTimeInterval )duration
68
+ {
69
+ NSAssert (message, @" 'message' must not be nil." );
70
+
71
+ __block CSNotificationView* note = [[CSNotificationView alloc ] initWithParentViewController: viewController];
72
+ note.tintColor = tintColor;
73
+ note.image = image;
74
+ note.textLabel .font = font;
75
+ note.textLabel .textAlignment = textAlignment;
76
+ note.textLabel .text = message;
77
+
78
+ void (^completion)() = ^{[note setVisible: NO animated: YES completion: nil ];};
79
+ [note setVisible: YES animated: YES completion: ^{
80
+ double delayInSeconds = duration;
81
+ dispatch_time_t popTime = dispatch_time (DISPATCH_TIME_NOW, (int64_t )(delayInSeconds * NSEC_PER_SEC));
82
+ dispatch_after (popTime, dispatch_get_main_queue (), ^(void ){
83
+ completion ();
84
+ });
85
+ }];
86
+
87
+ }
88
+
61
89
+ (void )showInViewController : (UIViewController *)viewController
62
90
style : (CSNotificationViewStyle)style
63
91
message : (NSString *)message
You can’t perform that action at this time.
0 commit comments