问题描述
我想做出类似的用户界面为所有iPhone和我目前使用的自动布局,但我不知道如何创建使用`NSLayoutConstraint`这个`UI`?
I want to make similar ui for all iPhones & i am currently using auto layout for that, but i do not know how to create this `UI` using `NSLayoutConstraint`?
这个UI作品在小画面精美,但我想相同的用户界面更大的iPhone以及(保持一定量的按钮之间的空间)。我怎么能在这加约束来得到相同的用户界面为iPhone 4S。
This UI works fine in small screen but i want same ui for bigger iPhone as well(keep certain amount of space between buttons). how can i add constraint in this to get same ui as iPhone 4s.
有人帮我在这里。
Some one help me out here.
截图。
推荐答案
我个人发现试图使自动布局约束感code(以及使用NSLayoutConstraint)是相当混乱,很难理解。 VFL(可视化格式语言)是强大的,但我会建议,如果你是刚刚开始接触,然后自动布局故事板的工作或XIB文件可能会更容易(取决于你个人的preference)。
Personally I find that trying to make sense of Auto Layout constraints in code (and using NSLayoutConstraint) to be quite confusing and difficult to understand. VFL (Visual Format Language) is powerful but I would recommend if you are just starting out with Auto Layout then working in Storyboard or a XIB file may be easier (depends on your individual preference).
由于这是一个相当复杂的话题我已经把在学习基础知识很有帮助。
If you are just getting started with Auto Layout you may find the following presentation I made helpful in learning the basics.
下面是来自不同的模拟器了三个截图,显示了如何布局自动调整取决于屏幕尺寸:iPhone 5S,iPhone 6,和iPhone 6加:
Here are three screenshots from different simulators which show how the layout adjusts automatically depending on the screen size: iPhone 5s, iPhone 6, and iPhone 6 Plus:
从技术上讲,横向也被这些约束支持,但结果可能会或可能不适合您的要求。 (我不确定什么方向你计划的支持。)
Technically, landscape orientation is also supported by these constraints however the result may or may not fit your requirements. (I am unsure what orientations you are planning to support.)
这篇关于自动布局和放大器;对齐约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!