From 8992349953aebbe42316f32694323192b00cc984 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Wed, 17 May 2023 16:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89actionAxis=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHDemo/PHDemo/AlertVC.swift | 14 ++------------ Sources/ProHUD/Alert/AlertConfiguration.swift | 4 ---- Sources/ProHUD/Alert/AlertDefaultLayout.swift | 5 +---- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/PHDemo/PHDemo/AlertVC.swift b/PHDemo/PHDemo/AlertVC.swift index c50adb3..752c807 100644 --- a/PHDemo/PHDemo/AlertVC.swift +++ b/PHDemo/PHDemo/AlertVC.swift @@ -142,27 +142,19 @@ class AlertVC: ListVC { alert.vm.message = "本次消费需要你支付999软妹豆,确认支付吗?" alert.config.customActionStack { stack in stack.spacing = 0 - stack.axis = .vertical + stack.axis = .vertical // 竖排按钮 } } .onViewDidLoad { vc in guard let alert = vc as? Alert else { return } -// alert.add(contentSpacing: 30) -// let v = UIView() -// v.backgroundColor = UIColor("#f2f2f2") -// alert.add(subview: v).snp.makeConstraints { make in -// make.left.right.equalToSuperview() -// make.height.equalTo(1) -// } -// alert.add(contentSpacing: 16) func createLine() -> UIView { let v = UIView() v.backgroundColor = UIColor("#f2f2f2") return v } let btn1 = alert.add(action: "确认,以后不需要再提醒", style: .plain(textColor: UIColor("#14cccc"))) - btn1.contentEdgeInsets.top = 16 + btn1.contentEdgeInsets.top = 16 + 1 // 间距 + 线的高度 btn1.contentEdgeInsets.bottom = 16 let line1 = createLine() btn1.insertSubview(line1, at: 0) @@ -295,7 +287,6 @@ class AlertVC: ListVC { Alert(.loading) { alert in alert.vm.title = "在弹出过程中增加元素" alert.add(action: "OK", style: .gray) - alert.config.actionAxis = .vertical } .onViewWillAppear { vc in guard let alert = vc as? Alert else { return @@ -407,7 +398,6 @@ class AlertVC: ListVC { } else { // Fallback on earlier versions } - alert.config.actionAxis = .vertical alert.add(contentSpacing: 24) alert.add(action: "OK", style: .gray) } diff --git a/Sources/ProHUD/Alert/AlertConfiguration.swift b/Sources/ProHUD/Alert/AlertConfiguration.swift index 071ab4d..f5a8365 100644 --- a/Sources/ProHUD/Alert/AlertConfiguration.swift +++ b/Sources/ProHUD/Alert/AlertConfiguration.swift @@ -11,10 +11,6 @@ public extension Alert { class Configuration: ProHUD.Configuration { - - /// 指定排列方向(默认两个按钮水平排列,超过时垂直排列) - public var actionAxis: NSLayoutConstraint.Axis? - /// 堆叠深度 public var stackDepth: CGFloat = 30 diff --git a/Sources/ProHUD/Alert/AlertDefaultLayout.swift b/Sources/ProHUD/Alert/AlertDefaultLayout.swift index edc81e7..7424d7e 100644 --- a/Sources/ProHUD/Alert/AlertDefaultLayout.swift +++ b/Sources/ProHUD/Alert/AlertDefaultLayout.swift @@ -113,7 +113,7 @@ extension Alert: DefaultLayout { } func setDefaultAxis() { - guard isViewDisplayed == false && config.actionAxis == nil && config.customActionStack == nil else { return } + guard isViewDisplayed == false && config.customActionStack == nil else { return } let count = actionStack.arrangedSubviews.filter({ $0.isKind(of: UIControl.self )}).count guard count < 4 else { return } if (isPortrait && count < 3) || !isPortrait { @@ -227,9 +227,6 @@ extension Alert { mk.left.right.equalToSuperview() } } - if let axis = config.actionAxis { - actionStack.axis = axis - } } else { // 无按钮 for v in actionStack.arrangedSubviews {