AutoLayout 圆形 UIButton - 等效的垂直和水平尺寸
AutoLayout Circular UIButton - Equivalent Vertical and Horizontal Size
如何在 AutoLayout 中使 UIButton 的垂直距离等于 UIButton 的水平距离。
使用视觉格式语言,我目前可以使所有 UIButton 具有相同的高度或宽度,但我不知道如何指定它们相同。
我也不希望预定义此距离,我知道可以通过设置指标来实现。
你不能为此使用 vfl。
你必须使用方法...
AddConstraintForItem:attribute:relation:toItem:attribute:multiplier:constant.
或者类似的东西。
两个项目可以相同,两个属性设置一个为宽度,一个为高度。
想出了一个解决方案。您不能使用视觉格式语言,而是需要使用 NSLayoutConstraint constraintWithItem
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:forwardButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:forwardButton attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
[self.view addConstraint:constraint];
如何在 AutoLayout 中使 UIButton 的垂直距离等于 UIButton 的水平距离。
使用视觉格式语言,我目前可以使所有 UIButton 具有相同的高度或宽度,但我不知道如何指定它们相同。
我也不希望预定义此距离,我知道可以通过设置指标来实现。
你不能为此使用 vfl。
你必须使用方法...
AddConstraintForItem:attribute:relation:toItem:attribute:multiplier:constant.
或者类似的东西。
两个项目可以相同,两个属性设置一个为宽度,一个为高度。
想出了一个解决方案。您不能使用视觉格式语言,而是需要使用 NSLayoutConstraint constraintWithItem
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:forwardButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:forwardButton attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
[self.view addConstraint:constraint];