? ? ? 很多時候 系統(tǒng)給的彈框視圖并不能滿足我們,由于產品的要求? 不得不自定義彈框視圖 在這里我寫了一個自定義界面的彈框? 展示界面如下?

如果需要 可以在這個界面隨意添加你想要的效果 ?控制器代碼如下
#import "ViewController.h"#import "LHAlertView.h"@interface ViewController ()@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *alertBtn = [UIButton buttonWithType:UIButtonTypeCustom];
alertBtn.frame = CGRectMake(50, 100, 100, 50);
[alertBtn setTitle:@"點擊" forState:UIControlStateNormal];
alertBtn.backgroundColor = [UIColor grayColor];
[alertBtn addTarget:self action:@selector(alertBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:alertBtn];
}
//點擊按鈕 出現(xiàn)彈框
- (void)alertBtnClick{
LHAlertView *alertView = [[LHAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds];
alertView.delegate = self;
NSArray *btnTitleArr = @[@"取消",@"確定"];
[alertView setContentStr:@"出現(xiàn)彈框出出現(xiàn)" type:10 btnNum:2 btntitleArr:btnTitleArr];
UIView *keywindow = [[UIApplication sharedApplication] keyWindow];
[keywindow addSubview: alertView];
}
#pragma mark - 代理事件
- (void)clickBottomBtnWithView:(LHAlertView *)alterView andClickBtn:(UIButton *)clickBtn{
if(clickBtn.tag == 100){
NSLog(@"點擊了取消按鈕");
}else{
NSLog(@"點擊了確定按鈕");
}
}
- (void)clickOtherPayMoneyWithView:(LHAlertView *)alterView andOtherPayMoneyBtn:(UIButton *)payMoney{
NSLog(@"點擊了其他按鈕");
}
@end
demo連接: https://git.oschina.net/huanni/myAlertView.git