以编程方式更改中心X / Y的路线约束的乘数 [英] Programmatically Change multiplier of Alignment Constraint of Center X / Y

查看:93
本文介绍了以编程方式更改中心X / Y的路线约束的乘数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I programmatically change the multiplier in the simplest way?

对于Swift 2.0

For Swift 2.0

推荐答案

对于Y,如果您将图像的顶部设置为与SuperView顶部相等的常数,则常数为0。然后输入此代码:

So for Y, if you set the top of the image equal with a constant of 0 to the top of the superView. then enter this code:

@IBOutlet weak var topc: NSLayoutConstraint!


let heightOfSuperview = self.view.bounds.height
topc.constant = heightOfSuperview * 0.90 // this has the same effect as multiplier  

这等于Center.y乘数= 0.9:1

This is equivalent of Center.y multiplier = 0.9:1

这篇关于以编程方式更改中心X / Y的路线约束的乘数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆