At very beginning, I want to just create every textField by my self-design function:
func creatTextField(x x0:Int,y y0: Int,w w0: Int,h h0: Int) -> UITextField{
let x = CGFloat(x0)
let y = CGFloat(y0)
let w = CGFloat(w0)
let h = CGFloat(h0)
let frame = CGRectMake(0, 0, w, h)
let center = CGPointMake(x/2, y/2)
let tf = UITextField(frame: frame)
tf.center = center
view.addSubview(tf)
return tf
}
and In the viewDidLoad(),I just want to add a new TextField:
override func viewDidLoad() {
super.viewDidLoad()
TextField = creatTextField(x: 50, y: 50, w: 100, h: 30)
}
And nothing changed when I ran the program
I am considering that did I miss something such as CONSTRAIN or I should use STACK VIEW to present those textFields correctly?
I hope someone can help me out! :D
b.t.w. Because it just a test, I just add one textField.But I should be a 2D-Array< UITextField >