先看效果:
主要代码如下:
- @implementation ViewController
- - (IBAction)loadingBtn:(UIButton *)sender {
-
- [self.view endEditing:YES];
- NSString *QQNumber = self.qqNumber.text;
- NSString *QQPwd = self.pwd.text;
- NSLog(@"用户QQ号码是:%@, 密码:%@",QQNumber,QQPwd);
-
- if ([QQNumber isEqualToString:@"123456"] && [QQPwd isEqualToString:@"qwert"]) {
- sender.hidden = YES;
- self.act.hidden = NO;
- self.showLoadLabel.hidden = NO;
- [self.act startAnimating];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self showLoadedSuccess];
-
- });
- }else{
-
- //创建弹框
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码或账号不正确" preferredStyle:UIAlertControllerStyleAlert];
- self.alert = alert;
- //给弹框添加按钮
- UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSLog(@"点击了");
- }];
- [alert addAction:alertAction];
-
- //显示弹框
- [self presentViewController:alert animated:YES completion:^{
- NSLog(@"点击了");
- }];
- }
-
-
- }
- - (void)showLoadedSuccess{
- [self.act stopAnimating];
- [self.showLoadLabel setText:@"登入成功"];
- self.act.hidden = YES;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
-
- self.act.hidden = YES;
- self.showLoadLabel.hidden = YES;
- }
复制代码
|
|