Ios 识别非NSContentSizeLayoutConstraint或类似的高度/宽度约束

Ios 识别非NSContentSizeLayoutConstraint或类似的高度/宽度约束,ios,xcode,nslayoutconstraint,Ios,Xcode,Nslayoutconstraint,我尝试以一般方式“获取”视图的宽度/高度约束,也就是说,不在约束上设置标识符/标记。系统会安装其他约束(例如NSContentSizeLayoutConstraint,但还有其他私有类) 它们都是NSLayoutConstraint类,相同的firstItem,属性,在我能想到的任何属性中都有相似的属性 我正在寻找一种方法来区分我安装的和其他安装的。这可以使用以下方法来完成:NSStringFromClass(type(of:)或String(description:type(of:)),这将返

我尝试以一般方式“获取”视图的宽度/高度约束,也就是说,不在约束上设置标识符/标记。系统会安装其他约束(例如
NSContentSizeLayoutConstraint
,但还有其他私有类)

它们都是
NSLayoutConstraint
类,相同的
firstItem
属性
,在我能想到的任何属性中都有相似的属性


我正在寻找一种方法来区分我安装的和其他安装的。

这可以使用以下方法来完成:
NSStringFromClass(type(of:)
String(description:type(of:))
,这将返回
NSContentSizeLayoutConstraint
NSLayoutConstraint

if String(describing: type(of: constraintInstance)) == "NSLayoutConstraint" {
    // This is not a system constraint
}
或类型(of:constraintInstance)==NSLayoutConstraint.self