Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS自动布局设计:随着设备高度的变化增加按钮高度_Ios_Autolayout_Constraints_Swift3 - Fatal编程技术网

iOS自动布局设计:随着设备高度的变化增加按钮高度

iOS自动布局设计:随着设备高度的变化增加按钮高度,ios,autolayout,constraints,swift3,Ios,Autolayout,Constraints,Swift3,在我的应用程序中,我添加了一个带有以下约束的ui按钮: Leading space = 10 Trailing space = 10 Height = 50 Bottom space =10 通过这个,我在设备的底部得到了一个按钮。它在单个设备(iPhone4)上运行良好,但随着设备高度的增加,按钮高度保持不变(iPhone6) 我还想用自动布局更改按钮高度 我尝试了一些建议添加乘数值的示例,但没有成功 我正在使用Xcode-8和Swift3 请推荐我 处理这个问题有多种方法 第一:- 创建1

在我的应用程序中,我添加了一个带有以下约束的
ui按钮

Leading space = 10
Trailing space = 10
Height = 50
Bottom space =10
通过这个,我在设备的底部得到了一个
按钮。它在单个设备(iPhone4)上运行良好,但随着设备高度的增加,按钮高度保持不变(iPhone6)

我还想用
自动布局
更改按钮高度

我尝试了一些建议添加
乘数
值的示例,但没有成功

我正在使用Xcode-8和Swift3


请推荐我

处理这个问题有多种方法 第一:- 创建1,为按钮提供固定高度约束 2.创建高度约束的@IBOutlet 这样

 @IBOutlet weak var btnHeightConstraint: NSLayoutConstraint!

   3. Set Constraint constant as per your requirement
像这样

btnHeightConstraint.constant = 50 //your button height 50
btnHeightConstraint.constant = 60 //your button height 60

设置所需的所有常量,并使用“superview”设置“等高”约束,并设置乘数值,即如果视图大小与iphone 5相同,则将乘数值设置为“yourHeight:568”,您将获得所需的输出。

添加乘数有助于解决问题