所以我的代碼看起來像這樣,針對每個已知的文本字段並對它們應用相同的修改器。是否可以選擇視圖中的所有文本字段?
有沒有什麼辦法可以選擇視圖中的所有文本框?
import UIKit
class CreateAccount: UIViewController, UITextFieldDelegate, UIScrollViewDelegate {
@IBOutlet weak var scrollViewer: UIScrollView!
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var reenterPasswordTextField: UITextField!
let textFieldBorderColor: UIColor = UIColor(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0)
let textFieldBorderFocusedColor: UIColor = UIColor(red: 31.0/255.0, green: 111.0/255.0, blue: 217.0/255.0, alpha: 1.0)
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
usernameTextField.layer.borderColor = textFieldBorderColor.CGColor
emailTextField.layer.borderColor = textFieldBorderColor.CGColor
passwordTextField.layer.borderColor = textFieldBorderColor.CGColor
reenterPasswordTextField.layer.borderColor = textFieldBorderColor.CGColor
usernameTextField.layer.borderWidth = 1.0
emailTextField.layer.borderWidth = 1.0
passwordTextField.layer.borderWidth = 1.0
reenterPasswordTextField.layer.borderWidth = 1.0
scrollViewer.delegate = self
}
}