首页 > 其他 > 详细

自定义alert

时间:2016-01-26 10:26:26      阅读:212      评论:0      收藏:0      [点我收藏+]

 

前提是要导入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];

    

}

 

自定义alert

原文:http://www.cnblogs.com/wangkaizheng/p/5159286.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!