简体   繁体   English

iOS自动布局约束

[英]IOS auto layout constraints

having trouble with my first app login screen... it looks good on iphone 8 screen size 我的第一个应用程序登录屏幕出现问题...在iPhone 8屏幕尺寸上看起来不错

在iPhone 8上

but when the screen is smaller - the images go off screen. 但是当屏幕较小时-图像会离开屏幕。

苹果手机

i use auto-layout with interface builder. 我使用自动布局与界面生成器。

tried playing around with the constraints: - spacing less or equal with high priority - use a stack view - autoshrink on the text label - compression resistance 尝试了以下约束:-以高优先级间隔或小于或等于-使用堆栈视图-在文本标签上自动收缩-耐压缩性

so far couldn't get the right set of constraints for it to work. 到目前为止,还没有获得正确的约束条件才能使其正常工作。

anyone? 任何人?

Update following the comments: 更新以下评论:

these are my constraints: 这些是我的约束: 在此处输入图片说明 and autoshrink on the label with "minimum font scale" 并使用“最小字体比例”在标签上自动缩小

i want the the images will get closer to the text, and the text to shrink so they all will be shown in one line. 我希望图像会更靠近文本,并且文本会缩小,因此它们全部都将显示在一行中。

You need to anchor the images to the edges, then it will shrink the font size as long as you have set Autoshrink . 您需要将图像锚定到边缘,然后只要设置了Autoshrink ,它就会缩小字体大小。 Connect as the image below. 连接如下图。

Basically, it is connected like this 基本上这样连接
|<-->image<-->label<-->image<-->|
Then set them images to fixed sizes, and let the label size itself. 然后将它们设置为固定大小的图像,并让标签本身大小。
You also need to position them on the Y axis. 您还需要将它们放置在Y轴上。

在此处输入图片说明

I have done with this 我已经完成了

在此处输入图片说明

The following result in iPhone 5s iPhone 5s的以下结果

在此处输入图片说明

and 8 plus 和8加

在此处输入图片说明

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

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