简体   繁体   English

使用约束放大不同屏幕尺寸的按钮

[英]Enlarging buttons for different screen sizes using constraints

still struggling with this one. 仍在为此奋斗。 I am tying to create a kind of on screen keyboard and have a layout of UIButtons like so: 我想创建一种屏幕键盘,并按如下方式布局UIButton:

在此处输入图片说明

I want to buttons to scale up as the screen does to make it more comfortable for larger devices eg: 我想像屏幕一样按比例放大按钮,以使其适合较大的设备,例如:

在此处输入图片说明

Some rows will have an odd number of buttons and some will have an even number. 有些行的按钮数为奇数,有些行的数为偶数。 I am putting each row of buttons inside separate holder views. 我将每行按钮放在单独的支架视图中。 Not totally clear how I should set up the constraints on the holder view. 尚不清楚我应该如何对持有人视图设置约束。 Should I pin the holder to the leading and trailing superview edges, and constrain the aspect ratio? 我应该将固定器固定在Superview的前缘和后缘,并限制长宽比吗?

For the top row I have tried adding separators between the buttons. 对于第一行,我尝试在按钮之间添加分隔符。 I then tried this: 然后我尝试了这个:

Button3.width = Button3.height (aspect ratio)

Button3.width = HolderView.superview.width * (1/5) - 10

Button3.trailing to Spacer, Button4.leading to Spacer

Button3 bottom/top constraints to superview

Can't seem to get any blue lines though. 不过似乎看不到任何蓝线。 Any instructions on how to proceed with this would be greatly appreciated!! 任何有关如何进行此操作的说明将不胜感激!! Thanks 谢谢

take a quick look at my demo project: https://www.dropbox.com/sh/vlozb5uxjor0ryd/AACOio_P6gorNvsSATxtdqP4a?dl=0 . 快速浏览一下我的演示项目: https : //www.dropbox.com/sh/vlozb5uxjor0ryd/AACOio_P6gorNvsSATxtdqP4a?dl=0 i have some plans now and try to explain it later... ;) 我现在有一些计划,请稍后再解释...;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM