如何在Swift Playground中获取布局跟踪

时间:2015-07-31 11:11:34

标签: ios xcode swift swift-playground

我在Swift游乐场中对一些视图进行原型设计。

import UIKit
import XCPlayground

let containerView = UIView(frame: CGRect(origin: CGPointZero, size: CGSize(width: 320, height: 300)))

XCPShowView("Container View", containerView)

我正在使用此容器视图来引入一些视图并使用约束来布局它们。 现在我真的想从中获取LayoutTrace,就像来自

的那个
po [[UIWindow keyWindow] _autolayoutTrace]

这样我就可以轻松找到一些不明确的布局。

任何想法?

1 个答案:

答案 0 :(得分:3)

您可以使用Objective-C运行时的valueForKey从Swift Playground访问_autolayoutTrace

print(containerView.valueForKey("_autolayoutTrace"))