From 40724785690264597ed097c3aa4ae1ede16a644f Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Thu, 24 Aug 2023 18:32:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9iOS13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/ProHUD/Capsule/CapsuleDefaultLayout.swift | 3 ++- Sources/ProHUD/Capsule/CapsuleManager.swift | 1 - Sources/ProHUD/Capsule/CapsuleTarget.swift | 7 +------ Sources/ProHUD/Capsule/CapsuleWindow.swift | 3 +++ 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Sources/ProHUD/Capsule/CapsuleDefaultLayout.swift b/Sources/ProHUD/Capsule/CapsuleDefaultLayout.swift index 75f15d4..0811d15 100644 --- a/Sources/ProHUD/Capsule/CapsuleDefaultLayout.swift +++ b/Sources/ProHUD/Capsule/CapsuleDefaultLayout.swift @@ -33,7 +33,8 @@ extension CapsuleTarget: DefaultLayout { textLabel.snp.remakeConstraints { make in make.width.lessThanOrEqualTo(AppContext.appBounds.width * 0.5) } - textLabel.snp.contentHuggingVerticalPriority = .infinity + textLabel.setContentCompressionResistancePriority(.required, for: .horizontal) + textLabel.setContentCompressionResistancePriority(.required, for: .vertical) textLabel.text = text textLabel.sizeToFit() } diff --git a/Sources/ProHUD/Capsule/CapsuleManager.swift b/Sources/ProHUD/Capsule/CapsuleManager.swift index a33e01b..80e5900 100644 --- a/Sources/ProHUD/Capsule/CapsuleManager.swift +++ b/Sources/ProHUD/Capsule/CapsuleManager.swift @@ -55,7 +55,6 @@ extension CapsuleTarget { config.cardCornerRadius = min(size.height / 2, config.cardCornerRadiusByDefault) contentView.layer.cornerRadiusWithContinuous = config.cardCornerRadiusByDefault - view.layer.cornerRadiusWithContinuous = config.cardCornerRadiusByDefault window.rootViewController = self // 此时toast.view.frame.size会自动更新为window.frame.size diff --git a/Sources/ProHUD/Capsule/CapsuleTarget.swift b/Sources/ProHUD/Capsule/CapsuleTarget.swift index a8934bf..7dfde5e 100644 --- a/Sources/ProHUD/Capsule/CapsuleTarget.swift +++ b/Sources/ProHUD/Capsule/CapsuleTarget.swift @@ -15,11 +15,9 @@ open class CapsuleTarget: BaseController, HUDTargetType { /// 内容容器(imageView、textLabel) public lazy var contentStack: StackView = { - let stack = StackView() + let stack = StackView(axis: .horizontal) stack.spacing = 8 - stack.distribution = .equalCentering stack.alignment = .center - stack.axis = .horizontal config.customContentStack?(stack) return stack }() @@ -80,9 +78,6 @@ open class CapsuleTarget: BaseController, HUDTargetType { open override func viewDidLoad() { super.viewDidLoad() - view.layer.shadowRadius = 8 - view.layer.shadowOffset = .init(width: 0, height: 5) - view.layer.shadowOpacity = 0.1 // 点击 let tap = UITapGestureRecognizer(target: self, action: #selector(_onTappedGesture(_:))) diff --git a/Sources/ProHUD/Capsule/CapsuleWindow.swift b/Sources/ProHUD/Capsule/CapsuleWindow.swift index ab0c20b..381a8c6 100644 --- a/Sources/ProHUD/Capsule/CapsuleWindow.swift +++ b/Sources/ProHUD/Capsule/CapsuleWindow.swift @@ -28,6 +28,9 @@ class CapsuleWindow: Window { windowLevel = .phCapsuleBottom } frame = .init(x: 0, y: 0, width: 128, height: 48) + layer.shadowRadius = 8 + layer.shadowOffset = .init(width: 0, height: 5) + layer.shadowOpacity = 0.1 isHidden = true }