From 90f63bb40646467469e8c588addb446c600cf977 Mon Sep 17 00:00:00 2001 From: zhangtao Date: Sun, 23 Feb 2025 14:08:53 +0800 Subject: [PATCH] fix compile err; add removeUserAddedConstraints function; --- Sources/Stevia/Stevia+Constraints.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sources/Stevia/Stevia+Constraints.swift b/Sources/Stevia/Stevia+Constraints.swift index fac2fcd..5819f7f 100644 --- a/Sources/Stevia/Stevia+Constraints.swift +++ b/Sources/Stevia/Stevia+Constraints.swift @@ -10,7 +10,7 @@ import UIKit public class SteviaLayoutConstraint: NSLayoutConstraint { - public static var defaultPriority: Float = UILayoutPriority.defaultHigh + 1 + public static var defaultPriority: Float = UILayoutPriority.defaultHigh.rawValue + 1 } @@ -106,6 +106,20 @@ public extension UIView { c is SteviaLayoutConstraint } } + + @MainActor + @discardableResult + func removeUserAddedConstraints() -> Self { + removeConstraints(userAddedConstraints.filter { + $0.firstItem === self + }) + if let superview { + superview.removeConstraints(superview.userAddedConstraints.filter { + $0.firstItem === self + }) + } + return self + } } // MARK: - Other