前提是要导入CustomIOS7AlertView包
CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] init];
[alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"上一个", @"确定", @"下一个", nil]];
UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 120)];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 180, 20)];
title.text = @"请填写姓名";
[demoView addSubview:title];
UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(10, 50, 270, 30)];
UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(10, 85, 270, 30)];
textField1.backgroundColor = [UIColor whiteColor];
textField1.returnKeyType = UIReturnKeyDone;
textField2.backgroundColor = [UIColor whiteColor];
textField2.returnKeyType = UIReturnKeyDone;
textField1.delegate = self;
[demoView addSubview:textField1];
// textField2.delegate = self;
[demoView addSubview:textField2];
[alertView setContainerView:demoView];//把demoView添加到自定义的alertView中
//这里是点击按钮之后触发的事件
[alertView setOnButtonTouchUpInside:^(CustomIOS7AlertView *alertView, int buttonIndex) {
if (buttonIndex==0) {//上一个
NSLog(@"上一个");
} else if (buttonIndex==1) {//确定
NSLog(@"确定");
NSLog(@"texeValue:%@",textField1.text);
} else if (buttonIndex == 2){//先保存数据,然后跳到下一个
NSLog(@"下一个");
}
}];
[alertView show];
}
原文:http://www.cnblogs.com/wangkaizheng/p/5159286.html