Password With Show hide button
import UIKit class PasswordTextField: UITextField { private let toggleButton = UIButton(type: .custom) override init(frame: CGRect) { super.init(frame: frame) setupView() } required init?(coder: NSCoder) { super.init(coder: coder) setupView() } private func setupView() { isSecureTextEntry = true borderStyle = .roundedRect rightViewMode = .always setupToggleButton() } private func setupToggleButton() { let buttonSize = CGSize(width: 24, height: 24) toggleButton.setImage(UIImage(systemName: "eye.fill"), for: .normal) toggleButton.frame = CGRect(origin: .zero, size: buttonSize) toggleButton.contentMode = .scaleAspectFit toggleButton.addTarget(self, action: #selector(togglePasswordVisibility), for: .touchUpInside) rightView = toggleButton addConstraints() } private func addConstraints() {