[英]Align image vertically in Swift 3
I am trying to vertically align a image in swift 3, but the following code is not working, I don't know why? 我正在尝试在swift 3中垂直对齐图像,但是以下代码不起作用,我不知道为什么?
addConstraint(NSLayoutConstraint(item: iconImageView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0))
Any ideas? 有任何想法吗?
The code above was fine but it was the following code that I changed: 上面的代码很好,但是我更改了以下代码:
From 从
addConstraintsWithFormat(format:"V:|[v0(30)]|", views: iconImageView)
To 至
addConstraintsWithFormat(format:"V:[v0(30)]", views: iconImageView)
Works fine now 现在工作正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.