以编程方式更改中心X/Y的Alignement约束的乘数

Jam*_*ams 5 constraints ios swift

如何以最简单的方式以编程方式更改乘数?

在此输入图像描述

对于Swift 2.0

Jam*_*ams 7

因此,对于Y,如果将图像的顶部设置为等于0的常量到superView的顶部.然后输入以下代码:

@IBOutlet weak var topc: NSLayoutConstraint!


let heightOfSuperview = self.view.bounds.height
topc.constant = heightOfSuperview * 0.90 // this has the same effect as multiplier  
Run Code Online (Sandbox Code Playgroud)

这相当于Center.y乘数= 0.9:1