//
// ViewController.m
// AlertController
//
// Created by Zhanggaoju on 2018/9/4.
// Copyright © 2018年 Zhanggaoju. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton*payBtn= [[UIButtonalloc]initWithFrame:CGRectMake(130,150,150,30)];
[payBtnaddTarget:self action:@selector(payClick) forControlEvents:UIControlEventTouchUpInside];
[payBtnsetTitle:@"去支付" forState:UIControlStateNormal];
[payBtnsetTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[self.viewaddSubview:payBtn];
}
-(void)payClick{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"请输入支付密码" preferredStyle:UIAlertControllerStyleAlert];
[alertControlleraddAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[alertControlleraddAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UITextField*userNameTextField = alertController.textFields.firstObject;
NSLog(@"支付密码:%@",userNameTextField.text);
}]];
[alertControlleraddTextFieldWithConfigurationHandler:^(UITextField*_NonnulltextField) {
textField.placeholder=@"请输入支付密码";
textField.secureTextEntry=YES;
}];
[self presentViewController:alertController animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
网友评论