import UIKit
class SignInViewController: UIViewController {
let introLabel = UILabel()
let iconImageView = UIImageView()
let idTextField = UITextField()
let passwordTextField = UITextField()
let loginButton = CustomButton(fontColor: .white, backColor: .black, title: "로그인")
let signupButton = CustomButton(fontColor: .black, backColor: .clear, title: "회원가입")
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
configureUI()
}
@objc func toSignupView(){
navigationController?.pushViewController(SignUpViewController(), animated: true)
}
func configureUI() {
configureIconImageView()
configureIntroLable()
configureIdTextField()
configureLoginButton()
configureSignUpButton()
configurePasswordTextField()
}
func configureIconImageView() {
view.addSubview(iconImageView)
iconImageView.image = UIImage(systemName: "film.stack")
iconImageView.contentMode = .center
iconImageView.tintColor = .red
iconImageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
iconImageView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 200),
iconImageView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 30),
iconImageView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -30)
])
}
func configureIntroLable() {
view.addSubview(introLabel)
introLabel.text = "안녕하세요!\nMOVIE66 입니다."
introLabel.numberOfLines = 0
introLabel.textAlignment = .center
introLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
introLabel.topAnchor.constraint(equalTo: iconImageView.bottomAnchor, constant: 10),
introLabel.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 30),
introLabel.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -30)
])
}
func configureIdTextField() {
view.addSubview(idTextField)
idTextField.placeholder = "아이디 입력"
idTextField.borderStyle = .roundedRect
idTextField.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
idTextField.topAnchor.constraint(equalTo: introLabel.bottomAnchor, constant: 60),
idTextField.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 30),
idTextField.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -30)
])
}
func configurePasswordTextField() {
view.addSubview(passwordTextField)
passwordTextField.placeholder = "비밀번호 입력"
passwordTextField.borderStyle = .roundedRect
passwordTextField.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
passwordTextField.topAnchor.constraint(equalTo: idTextField.bottomAnchor, constant: 10),
passwordTextField.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
passwordTextField.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30)
])
}
func configureLoginButton() {
view.addSubview(loginButton)
NSLayoutConstraint.activate([
loginButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 420),
loginButton.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 30),
loginButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -30)
])
}
func configureSignUpButton() {
view.addSubview(signupButton)
signupButton.addTarget(self, action: #selector(toSignupView), for: .touchUpInside)
NSLayoutConstraint.activate([
signupButton.topAnchor.constraint(equalTo: loginButton.bottomAnchor, constant: 10),
signupButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
signupButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30)
])
}
}