UIAlertController contentViewController

    override func bindViewModel() {
        nextButton.rx.tap.sink { _ in
            Toolbox.addShadowMask()
            let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
            let cancelAction = UIAlertAction(title: "Common_Cancel".localized(), style: .cancel) { _ in
                Toolbox.removeShadowMask()
            }
            let sureAddressAction = UIAlertAction(title: "", style: .default, handler: { _ in
                Toolbox.removeShadowMask()
                SceneAgent.popToViewController(for: ProfileViewController.self, animated: false)
                SceneAgent.pushPhoneOrEmailEdit(type: .emailNoVerified)
            })
            let updateAddressAction = UIAlertAction(title: "Quick_Access_Card_Update_Address".localized(), style: .default, handler: { _ in
                Toolbox.removeShadowMask()
                SceneAgent.popToViewController(for: ProfileViewController.self, animated: false)
                SceneAgent.pushPhoneOrEmailEdit(type: .emailNoVerified)
            })
            alertController.setValue(AlertHeaderViewController(), forKey: "contentViewController")
            sureAddressAction.setValue(AlertActionViewController(), forKey: "contentViewController")
            alertController.addAction(cancelAction)
            alertController.addAction(sureAddressAction)
            alertController.addAction(updateAddressAction)
            SceneAgent.present(vc: alertController, animated: true)
        }.disposed(by: rx.disposeBag)
    }

class AlertHeaderViewController: UIViewController {
   
    private lazy var titleLabel = UILabel().then {
        $0.attributedText = attributedText("""
            \(SettingViewModel.userAddrees, .font(UIFont.cheeseFont("SFProText-Regular", size: 13.pt)), .color(Theme.BlueGreyColor5), .alignment(.center))
            """)
        $0.numberOfLines = 0
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(titleLabel)
    
        titleLabel.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.height.equalTo(70)
            make.top.equalTo(10)
            make.bottom.equalTo(-10)
        }
    }
}

class AlertActionViewController: UIViewController {
   
    private lazy var actionButton = UIButton().then {
        $0.setImage(UIImage(named: "contactless_card")?.withRenderingMode(.alwaysOriginal), for: UIControl.State())
        $0.setTitle("Quick_Access_ActionSheet_ConfirmButtonTile".localized(), for: UIControl.State())
        $0.setTitleColor(UIColor.colorForHex("007AFF"), for: UIControl.State())
        $0.imageEdgeInsets = UIEdgeInsets(top: 0, left: -20, bottom: 0, right: 0)
        $0.titleLabel?.font = .H1Medium
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(actionButton)
    
        actionButton.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
}

extension UIAlertController {
    static var propertyNames: [String] {
        var outCount: UInt32 = 0
        guard let ivars = class_copyIvarList(self, &outCount) else {
            return []
        }
        var result = [String]()
        let count = Int(outCount)
        for i in 0..

你可能感兴趣的:(UIAlertController contentViewController)