centerXAnchor仅在iOS 9.0或更高版本中可用?
因此,我尝试以编程方式添加约束:centerXAnchor仅在iOS 9.0或更高版本中可用?,ios,swift3,nslayoutconstraint,xcode8.2,Ios,Swift3,Nslayoutconstraint,Xcode8.2,因此,我尝试以编程方式添加约束: 我只是添加了两个约束,Xcode开始向我展示: centerXAnchor仅在iOS 9.0或更高版本中可用 这是我的密码: var constraints = [NSLayoutConstraint]() let centerImageX = imageView.centerXAnchor.constraint(equalTo: footerView.centerXAnchor) let centerImageY = imageView.centerYAn
我只是添加了两个约束,Xcode开始向我展示: centerXAnchor仅在iOS 9.0或更高版本中可用 这是我的密码:
var constraints = [NSLayoutConstraint]()
let centerImageX = imageView.centerXAnchor.constraint(equalTo: footerView.centerXAnchor)
let centerImageY = imageView.centerYAnchor.constraint(equalTo: footerView.centerYAnchor)
constraints = [centerImageX,centerImageY]
NSLayoutConstraint.activate(constraints)
我想和大家分享的一件事可能是难以置信的,几天前我没有收到任何错误消息
我的Xcode版本是8.2.1
另外,我的部署目标是
8.0
及以上版本。所以,如果有人能告诉我,或者能为iOS 8.0转换或翻译相同的代码,那就太棒了 这应该做同样的工作:
self.view.addConstraint(NSLayoutConstraint(item: imageView, attribute: .centerX, relatedBy: .equal, toItem: footerView, attribute: .centerX, multiplier: 1.0, constant: 0))
self.view.addConstraint(NSLayoutConstraint(item: imageView, attribute: .centerY, relatedBy: .equal, toItem: footerView, attribute: .centerY, multiplier: 1.0, constant: 0))