美文网首页
(IOS)原生输入框弹框

(IOS)原生输入框弹框

作者: rightmost | 来源:发表于2018-09-04 17:11 被阅读0次

//

//  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

相关文章

网友评论

      本文标题:(IOS)原生输入框弹框

      本文链接:https://www.haomeiwen.com/subject/kiqnwftx.html