UI들을 Reusable 하게 함수로 만들어 버렸다
class Utilities {
func inputContainerView(with image: UIImage, textField: UITextField) -> UIView {
let view = UIView()
let imageView = UIImageView()
let dividerView = UIView()
imageView.image = image
dividerView.backgroundColor = .white
view.addSubview(imageView)
view.snp.makeConstraints {
$0.height.equalTo(50)
}
imageView.snp.makeConstraints {
$0.leading.equalToSuperview()
$0.bottom.equalToSuperview().inset(8)
$0.width.height.equalTo(24)
}
view.addSubview(textField)
textField.snp.makeConstraints {
$0.leading.equalTo(imageView.snp.trailing).offset(8)
$0.bottom.equalToSuperview().inset(8)
$0.trailing.equalToSuperview()
}
view.addSubview(dividerView)
dividerView.snp.makeConstraints {
$0.leading.equalToSuperview()
$0.bottom.equalToSuperview()
$0.trailing.equalToSuperview()
$0.height.equalTo(0.75)
}
return view
}
func textField(withPlaceholder placeholder: String) -> UITextField {
let tf = UITextField()
tf.textColor = .white
tf.attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])
return tf
}
}