如何确定是否使用自动布局来制作情节提要或 Xib



在iOS中,有没有办法以编程方式找出故事板或xib是否使用Auto Layout或Springs & Struts定义?

在编写需要能够对任一方法进行操作的方法时,这将很有用。

您可以检查包含的视图以获取 view.constraints 属性。

具体说来:

if (someView.constraints.count) { 
    // Autolayout
} else {
    // Sprints & struts
}

也许通过检查布尔值translatesAutoresizingMaskIntoConstraints

最新更新