如何使4个uibutton以相等的距离居中? [英] How do I center 4 uibuttons with equal distance from each other?

查看:684
本文介绍了如何使4个uibutton以相等的距离居中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个uibutton。每个按钮必须是100x100。我想把他们中的4个在我的屏幕的中心(水平),但垂直放下。我不知道从哪里开始,但我听说stackviews可能工作?不确定。我尝试使用基本约束,但我无法让他们工作。



这里是我试图得到:

解决方案

步骤1: - 步骤2: - 将所有按钮的固定高度和宽度设为





b



步骤3: - 全部2 - 2










第5步:在一个Stackview中添加Stackview





步骤6:在主栈中设置 Distribution = Spill = 5 要求)





步骤7: - 现在将Constrain设置为主stackview

 中心水平放置在容器中

垂直居中container

并选择Update Frame。



步骤8: - 是输出为所有设备的时间。



< a>



我希望对你有帮助。


I have 4 uibuttons. Each button MUST be 100x100. I want to center the 4 of them in the center of my screen (horizontally), but put them down vertically. I have no idea where to start, but i've heard stackviews might work? Not sure. I tried using basic constraints, but i was unable to get them to work.

here is what im trying to get:

解决方案

Step 1 :- take 4 button in your Storyboard. Button1 , Button2 , Button 3 , Button4

Step 2 :- Give Fixed Height and width to All buttons .

Step 3 :- All 2 - 2 button's pair in 2 stackview.

Step 4 :- Set UIStackview Property for both .

      Distribution -> Fill Equally
           Spacing -> 5 (as per your requirement)


Step 5 :- Add both Stackview in one Stackview

Step 6 :- Set Distribution = Fill equally Spacing =5 in main stackview (set According to your requirement)

Step 7 :- Now set Constrain to main stackview

      center Horizontally in container

      center vertically in container

        and select Update Frame.

Step 8 :- It's time for Output for All device .

I hope it will be helpful for you.

这篇关于如何使4个uibutton以相等的距离居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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