I am trying to vertically align a image in swift 3, but the following code is not working, I don't know why?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.