-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyAlertView.m
48 lines (35 loc) · 1.5 KB
/
MyAlertView.m
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
//
// MyAlertView.m
// Saojie
//
// Created by William on 16/1/11.
// Copyright © 2016年 William. All rights reserved.
//
#import "MyAlertView.h"
@implementation MyAlertView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (self.alertBlock) {
self.alertBlock(alertView, buttonIndex);
}
}
- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate withMyAlertBlock:(MyAlertBlock)alertBlock cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...{
self = [ super initWithTitle:title message:message delegate:self cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil];
if (self) {
self.alertBlock = alertBlock;
}
return self;
}
+ (void)MyAlertWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate style:(UIAlertViewStyle)style withMyAlertBlock:(MyAlertBlock)alertBlock cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... {
MyAlertView * alert = [[MyAlertView alloc]initWithTitle:title message:message delegate:self withMyAlertBlock:alertBlock cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles];
alert.alertViewStyle = style;
[alert show];
}
@end