ActivationSchoolCardViewController.swift
3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
// ActivationSchoolCardViewController.swift
// ParentAssistant
//
// Created by 葛建军 on 2018/4/11.
// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
//
import UIKit
//校卡激活页面
class ActivationSchoolCardViewController: UIViewController,UITextFieldDelegate {
var info:StudentClassInfo!//孩子信息
lazy var showView = {()-> UIView in
let view = UIView.init(frame: CGRect.init(x: 10, y: 10, width: screenWidth-20, height: 110))
view.backgroundColor = UIColor.white
return view
}()
lazy var nameLable = {()-> UILabel in
let label = UILabel.init(frame: CGRect.init(x: 100, y: 20, width: 180, height: 30))
label.text = info.studentName
label.textAlignment = .center
return label
}()
lazy var cardNumberTextField = {()->UITextField in
let field = UITextField.init(frame: CGRect.init(x: 100, y: 70, width:180, height: 30))
field.delegate = self
field.textAlignment = .center
field.placeholder = "请输入卡号"
return field
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = backGroundColor
self.view.addSubview(self.showView)
drawUI()
}
func drawUI(){
let nameTitle = UILabel.init(frame: CGRect.init(x: 20, y: 20, width: 100, height: 30))
nameTitle.text = "持卡人:"
let cardTitle = UILabel.init(frame: CGRect.init(x: 20, y: 70, width: 100, height: 30))
cardTitle.text = "卡号:"
let btn = UIButton.init(frame: CGRect.init(x: 10, y: screenHeight-66-80, width: screenWidth-20, height: 40))
btn.setTitle("确定", for: UIControlState.normal)
btn.backgroundColor = Theme.topBarColor()
btn.layer.cornerRadius = 5
btn.clipsToBounds = true
btn.addTarget(self, action: #selector(activationAction(_:)), for: .touchUpInside)
showView.addSubview(nameTitle)
showView.addSubview(self.nameLable)
showView.addSubview(cardTitle)
showView.addSubview(self.cardNumberTextField)
self.view.addSubview(btn)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
return cardNumberTextField.resignFirstResponder()
}
// MARK: - 确定按钮
@objc func activationAction(_ sender: UIButton) {
if cardNumberTextField.text == "" {
self.view.makeToast("卡号不能为空")
}
let alert = UIAlertController.init(title: "卡号:\(cardNumberTextField.text!)", message: "已成功激活!", preferredStyle: UIAlertControllerStyle.alert)
let action = UIAlertAction.init(title: "返回", style: UIAlertActionStyle.default) { (action) in
self.dismiss(animated: true, completion: nil)
}
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}