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..<count {
let pro: Ivar = ivars[i]
guard let ivarName = ivar_getName(pro) else {
continue
}
guard let name = String(utf8String: ivarName) else {
continue
}
result.append(name)
}
return result
}
}
UIAlertController contentViewController
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 具体原因我认为是runloop没有及时更新UI。解决办法[selfpresentViewController:Al...
- 1.前言今天有个小伙伴问我,他在给tableViewCell添加选中事件的时候,调用UIAlertControll...
- 转自:https://www.jianshu.com/p/fed4cc7c8c94 习惯用UITableViewC...
- 调用[mAppDelegate.rootNavigationController presentViewContr...