使 UIButton 占屏幕大小的百分比

2023-07-07移动开发问题
2

本文介绍了使 UIButton 占屏幕大小的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我注意到某些按钮尺寸在 iPhone 5 模拟器上看起来很棒,但在 iPhone 6 模拟器上看起来不那么好,这是因为我放置在 UIButtons 上的高度或约束最终会留下很多空白空间我的应用屏幕底部.

I noticed certain button sizes look great on one the iPhone 5 simulator but do not look as good on the iPhone 6 simulator and this is because the heights or constraints that I place on the UIButtons end up leaving a lot of blank space down the bottom of my App Screen.

无论我在什么设备上模拟,我都希望有一个屏幕大小为 40% 的按钮.

I would like to have a button that is 40% of the screen size regardless of what device I am simulating on.

关于如何使按钮的大小保持在屏幕大小的 40% 而与设备无关的任何想法?

Any ideas on how to make the size of the button stay 40% of the screen size regardless of the device?

推荐答案

  1. Ctrl 从按钮拖到 superview 并选择 Equal Widths
  2. Open Size Inspector 编辑 Equal Widths 约束并将乘数设置为 0.4.你会看到这样的东西:

  1. Ctrl drag from button to superview and select Equal Widths
  2. Open Size Inspector edit Equal Widths constraint and set multiplier to 0.4. And you will see something like this:

添加缺失的约束并更新帧.

Add missing constraints and update frames.

这篇关于使 UIButton 占屏幕大小的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

cocos2D iPhone中的UItextfield文本对齐问题
UItextfield text alignment issue in cocos2D iPhone(cocos2D iPhone中的UItextfield文本对齐问题)...
2024-08-12 移动开发问题
7

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9

如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?
How can i use MYSQL database connection in iphone application useing cocos2d?(如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?)...
2024-08-12 移动开发问题
5