答案 0 :(得分:0)
答案 1 :(得分:0)
以上图为例:
1.i我知道你已经做了水平中心来查看约束。
2.添加前导约束来查看。
现在只需运行它就可以得到确切的要求.......
希望这会对你有帮助..
答案 2 :(得分:0)
您必须根据percentage(%)
添加约束,以便按钮图像可以根据device
(iPhone / iPad)screen size
而变化。
按钮上的StoryBoard约束
Step 1. Drag button and place it on its proper position.
Step 2. Now Add constraint Horizontal Center in Container.
Step 2. Now Add Bottom Pin constraint.
Step 3. Add constraint Equal Width and Equal Height.
Step 4. Now update multiplier of Equal Width constraint and Equal Height.
使用KVConstraintExtensionsMaster
以编程方式更新iPad上的约束。
- (void)viewDidLoad
{
[super viewDidLoad];
/* preparing View Hierarchy */
UIButton *button = [UIButton prepareNewViewForAutoLayout];
[self.view addSubview:button];
/* applying constraints */
[button applyConstraintForHorizontallyCenterInSuperview];
[button applyBottomPinConstraintToSuperviewWithPadding:defualtConstant];
[button applyWidthConstraint:280]; // fixed width for iphone
[button applyHeightConstrain:40]; // fixed height for iphone
// update width constraint with proper iPad ratio
[button updateAppliedConstraintConstantValueForIpadByAttribute:NSLayoutAttributeWidth];
// update height constraint with proper iPad ratio
[button updateAppliedConstraintConstantValueForIpadByAttribute:NSLayoutAttributeHeight];
/*
// update Height constraints at any specific ratio on iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[button updateAppliedConstraintConstantValueByAttribute:NSLayoutAttributeHeight withConstantRatio:1.8];
}
*/
}