์ค๋๋ง์ ์ปด๋ฐฑ ์ปจํ ์ธ ๋ ๋ฐ๋ก๋ฐ๋ก~ ์ง๋ ์ผ์ฃผ์ผ๊ฐ ์งํํ๋ ์ํ ์์ฝ ์ฑ ํ๋ก์ ํธ,
N2FLIX์ ๋ํ ๋ด์ฉ์ ๋๋ค!
์ N2FLIX๋! ํ๋ฉด... ํ์๋ค์ MBTI์ ๋ชจ๋ ๊ณตํต์ ์ผ๋ก N์ด ๋ค์ด๊ฐ์ ๊ทธ๋ ๋ต๋๋ค ํํ...
์ด์ฉ๋ค๋ณด๋ ํ์ฅ ์ญํ ์ ์ํํ๊ฒ ๋์๋๋ฐ, ํ๋ก์ ํธ KPT(Keep, Problem, Try) ๋ ๊ฐ์ ๋ฉค๋ฒ๋ก ๋๋ค๋ฅธ ํ๋ก์ ํธ๋ฅผ ํ๊ณ ์ถ์ ์ ๋๋ก ๋ถ์๊ธฐ๋ ์ข๊ณ , ํ์ ๋ชจ๋๊ฐ ๋ณธ์ธ์ ์ญํ ์ ์ถฉ์คํ ์ํํด์ฃผ์ ์ ์ข์ ๊ฒฐ๊ณผ๋ฌผ์ ์ป์ ์ ์์์ต๋๋ค.
์์ด์ด ํ๋ ์ ๋ฐ ๋์์ธ
์ฑ์ ํ์ํ ํ์ด์ง๋ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฑํ์ต๋๋ค
- ๋ก๊ทธ์ธ / ํ์๊ฐ์ ํ์ด์ง
- ์ํ ๋ชฉ๋ก ํ์ด์ง (๋ฉ์ธํ๋ฉด)
- ์ํ ์ ๋ณด ์์ธ ํ์ด์ง
- ์๋งค ํ์ด์ง
- ๊ฐ๋ด์์ ์ ํ์ด์ง
- ์ฐํ ์ํ ํ์ด์ง
- ๋ง์ดํ์ด์ง
Figma๋ฅผ ์ด์ฉํด ๋์์ธ ๋ฐ ์์คํ ์ํคํ ์ฒ๋ฅผ ํ์๋ค๊ณผ ํจ๊ป ์ด๋ค ์ฌ์ฉ์ ๊ฒฝํ์ ์ ๊ณตํ ์ ์๋์ง์ ๋ํ ์๊ฒฌ์ ์ผ์น์ํค๊ณ ๋์ ํ๋ก์ ํธ์ ๋์ ํ์์ต๋๋ค.
๋ก๊ทธ์ธ / ํ์๊ฐ์ ๊ธฐ๋ฅ
์ ๊ฐ ๋งก์ ๋ก๊ทธ์ธ / ํ์๊ฐ์ ํ์ด์ง๋ ์ฝ๋ ๋ฒ ์ด์ค๋ก ๊ตฌํ ํ์ต๋๋ค.
๋ค๋ง, ๋ณต์กํ ํ์๊ฐ์ ๊ณผ์ ์ ์ซ์ดํ๋ ์ฌ๋(๋๊ฐ...?)์ ์ํด ๊ธฐ์กด์ ๋ฑ๋ก๋์ด ์์ง ์์ ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ์ ์๋ํ ๊ฒฝ์ฐ ํ์๊ฐ์ ์ด ๋๋๋ก ๋ง๋ค์์ต๋๋ค!
๊ฐ์ฅ ๋จผ์ , ์ฌ์ฉ์์ Email๊ณผ PW๋ฅผ ์ ๋ ฅ๋ฐ๋ TextField์ ๋ก๊ทธ์ธ ๋ฒํผ('๋ค์')์ ์คํ ๋ทฐ ์์ ๋ฃ๊ณ , AutoLayout์ ์ก์ ์ฃผ์์ต๋๋ค.
SignUpView.swift
// MARK: - email ์
๋ ฅ ํ
์คํธ ๋ทฐ
private lazy var emailTextFieldView: UIView = {
let view = UIView()
view.backgroundColor = #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
view.layer.borderWidth = 2
view.layer.borderColor = #colorLiteral(red: 0.2757139802, green: 0.2757139802, blue: 0.2757139802, alpha: 1)
view.layer.cornerRadius = 5
view.clipsToBounds = true
view.addSubview(emailTextField)
view.addSubview(emailInfoLabel)
view.addSubview(emailClearButton)
return view
}()
private lazy var pwTextFieldView: UIView = {
let view = UIView()
view.frame.size.height = 48
view.backgroundColor = #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
view.layer.borderWidth = 2
view.layer.borderColor = #colorLiteral(red: 0.2757139802, green: 0.2757139802, blue: 0.2757139802, alpha: 1)
view.layer.cornerRadius = 5
view.clipsToBounds = true
view.addSubview(pwTextField)
view.addSubview(pwInfoLabel)
view.addSubview(pwClearButton)
view.addSubview(pwSecureButton)
return view
}()
// MARK: - ๋ค์(๋ก๊ทธ์ธ ์งํ) ๋ฒํผ
lazy var loginButton: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = .clear
button.layer.cornerRadius = 5
button.layer.borderWidth = 1
button.layer.borderColor = #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
button.setTitle("๋ค์", for: .normal)
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
button.isEnabled = false
return button
}()
// stack view
private lazy var stackView: UIStackView = {
let stview = UIStackView(arrangedSubviews: [emailTextFieldView, pwTextFieldView, loginButton])
stview.spacing = 20
stview.axis = .vertical
stview.distribution = .fillEqually
stview.alignment = .fill
return stview
}()
// MARK: - AutoLayout
private func stackViewConstraints() {
stackView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
stackView.centerXAnchor.constraint(equalTo: centerXAnchor),
stackView.centerYAnchor.constraint(equalTo: centerYAnchor),
stackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 30),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -30),
stackView.heightAnchor.constraint(equalToConstant: textViewHeight*3 + 40)
])
}
๊ทธ๋ฆฌ๊ณ Text ์ ๋ ฅ์ ์์ํ ๋์ ์ ๋ ฅ์ ๋๋์ ๋, Textfield์ ์๋ ๋ฌธ๊ตฌ์ ํฐํธ ํฌ๊ธฐ์ AutoLayout์ ์ฌ์ค์ ํ๋๋ก ํด ์ค์ ๋ทํ๋ฆญ์ค์ ๋ก๊ทธ์ธ ํ์ด์ง ๊ฐ์ ๋ฐฉ์์ ๊ตฌํํ์ต๋๋ค.
SignUpView.swift
// MARK: - Extension
extension SignUpView: UITextFieldDelegate {
// textfield ํธ์ง ์ ๋ฌธ๊ตฌ๊ฐ ์๋ก ์ฌ๋ผ๊ฐ๋ฉด์ ํฌ๊ธฐ๋ฅผ ์๊ฒ ๋ง๋ค๊ณ ์คํ ๋ ์ด์์ ์ฌ์ค์
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField == emailTextField {
emailTextFieldView.backgroundColor = #colorLiteral(red: 0.2972877622, green: 0.2973434925, blue: 0.297280401, alpha: 1)
emailTextFieldView.layer.borderColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
emailInfoLabel.font = UIFont.systemFont(ofSize: 11)
emailInfoLabelCenterYConstraint.constant = -13
}
if textField == pwTextField {
pwTextFieldView.backgroundColor = #colorLiteral(red: 0.2972877622, green: 0.2973434925, blue: 0.297280401, alpha: 1)
pwTextFieldView.layer.borderColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
pwInfoLabel.font = UIFont.systemFont(ofSize: 11)
pwInfoLabelCenterYConstraint.constant = -13
}
UIView.animate(withDuration: 0.3) {
self.stackView.layoutIfNeeded()
}
}
// textfield ํธ์ง ์ข
๋ฃ ์ ์ค์
func textFieldDidEndEditing(_ textField: UITextField) {
if textField == emailTextField {
emailTextFieldView.backgroundColor = #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
if emailTextField.text == "" {
emailTextFieldView.layer.borderColor = #colorLiteral(red: 0.2757139802, green: 0.2757139802, blue: 0.2757139802, alpha: 1)
emailInfoLabel.font = UIFont.systemFont(ofSize: 16)
emailInfoLabelCenterYConstraint.constant = 0
}
}
if textField == pwTextField {
pwTextFieldView.backgroundColor = #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
if pwTextField.text == "" {
pwTextFieldView.layer.borderColor = #colorLiteral(red: 0.2757139802, green: 0.2757139802, blue: 0.2757139802, alpha: 1)
pwInfoLabel.font = UIFont.systemFont(ofSize: 16)
pwInfoLabelCenterYConstraint.constant = 0
}
}
UIView.animate(withDuration: 0.3) {
self.stackView.layoutIfNeeded()
}
}
๊ทธ ์ธ์๋, ๋ด์ฉ์ ์ผ๊ด ์ญ์ ํ๋ ๋ฒํผ ๋ฐ PW Secure ๊ธฐ๋ฅ ํ ๊ธ ๋ฒํผ์ ์ถ๊ฐํ๊ณ ,
SignUpVC.swift์ ๋ก๊ทธ์ธ ๋ก์ง์ ๊ตฌํํ๊ณ ๋์, ์ด๋ฉ์ผ๊ณผ ๋น๋ฐ๋ฒํธ์ ๋ํ Validation์ ์ ์ฉํ์ต๋๋ค.
UserDataManger.swift
// id validation : @ ์์ ์ํ๋ฒณ, ์ซ์, ํน์๋ฌธ์๊ฐ ํฌํจ๋ ์ ์๊ณ @ ๋ค์๋ ์ํ๋ฒณ, ์ซ์, ๊ทธ๋ฆฌ๊ณ . ๋ค์๋ ์ํ๋ฒณ 2์๋ฆฌ ์ด์
func isValidEmail(email: String) -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
let emailTest = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
return emailTest.evaluate(with: email)
}
// pw validation : ์๋ฌธ์, ๋๋ฌธ์, ์ซ์ 8์๋ฆฌ ์ด์
func isValidPassword(pwd: String) -> Bool {
let passwordRegEx = "^[a-zA-Z0-9]{8,}$"
let passwordTest = NSPredicate(format: "SELF MATCHES %@", passwordRegEx)
return passwordTest.evaluate(with: pwd)
}
์ ์ฉ ํ๋ฉด
[๋๋จธ์ง ํ์ด์ง ๋ด์ฉ์ ์ถ๊ฐ ์ ๋ก๋ ์์ ์ ๋๋ค.]