如何在iPhone的uiview控制器中自动布局按钮? [英] How to AutoLayout the buttons in uiview controller in iphone?

查看:42
本文介绍了如何在iPhone的uiview控制器中自动布局按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的大小为4英寸,我在3个不同的行中添加了4个图标,大小均为60x60.我可以在iphone 4s,5、5s中看到正确的视图,但在iphone 6和6 plus中看不到.因此,如何在iphone 6和6 plus中对其应用自动布局,并使图标看起来更大并具有相同的比例.可以不用任何编码吗?

I have size of 4 inch and i have added 4 icons in 3 different rows of all equal size 60x60. I can have a proper view in iphone 4s,5,5s but not in iphone 6 and 6 plus. So how can i apply auto layout to it and make the icons look bigger and of same ratio in iphone 6 and 6 plus. Can this be made without any coding?

赞这个

此按钮应在iphone 6和6 plus中更改其大小,即应变大并正确对齐. 不用编码就可以吗?

This buttons should change its size in iphone 6 and 6 plus i.e. it should get bigger and proper aligned. Can it is possible without coding?

推荐答案

一个简单的示例:

  1. 将一个按钮从对象库拖到情节提要中的ViewController的视图中
  2. ctrl从按钮拖到视图(向左或向右拖动),然后选择在容器中垂直居中
  3. ctrl从按钮拖到视图中(拖动到顶部或底部),然后选择在容器中水平居中
  4. ctrl从按钮拖到按钮(是,相同的按钮),然后选择长宽比
  5. 在大小检查器中,检查按钮的宽高比约束以使其乘数为 1:1
  6. ctrl从按钮拖动到视图(向左或向右拖动),然后选择等宽
  7. 在大小检查器中,检查按钮的等宽约束是否具有乘数 1:3 (或您喜欢的任何值-1:3表示按钮的宽度是视图宽度的三分之一)宽度)
  1. drag a button from the object library to your viewcontroller's view in storyboard
  2. ctrl drag from your button to your view (drag to the left or the right) and choose center vertically in container
  3. ctrl drag from your button to your view (drag to the top or the bottom) and choose center horizontally in container
  4. ctrl drag FROM the button TO the button (yes, the same button) and choose aspect ratio
  5. in the size inspector check the button's aspect ratio constraint to have a multiplier of 1:1
  6. ctrl drag from your button to your view (drag to the left or the right) and choose equal widths
  7. in the size inspector check the button's equal width constraint to have a multiplier of 1:3 (or whatever value you like - 1:3 means that that the button's width is one third of the view's width)

应该的.祝你好运! :)

that should be it. good luck! :)

这篇关于如何在iPhone的uiview控制器中自动布局按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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