简体   繁体   English

约束照顾不同的iPhone / iPad尺寸的图像xcode 7 beta 4

[英]Constraints to take care of different iPhone/iPad sizes for images xcode 7 beta 4

I'm new to iOS development, so setting constraints for objects on the storyboard in Xcode has been difficult for me. 我是iOS开发的新手,因此在Xcode的情节提要中为对象设置约束非常困难。

As this picture below shows, I have 3 borders for buttons I created in sketch so they are all images, each of them inside of a image view: 如下图所示,我在素描中创建的按钮有3个边框,因此它们都是图像,每个图像都在图像视图中:

屏幕截图

I tried adding constraints by pinning all three images to the left, right and below themselves but I got errors for it and it did not come out right at all on the simulators. 我试图通过将所有三个图像固定在它们自己的左侧,右侧和下方来添加约束,但是我遇到了错误,并且在模拟器上根本没有出现。 All of the images are in aspect fill mode, and I have the view in the size of an iPhone 4 when I put the images in the storyboard. 所有图像都处于宽高比填充模式,将图像放入情节提要中时,可以看到iPhone 4的大小。 Here's an example of what it looks like in the iPhone 6 simulator without any constraints: 这是没有任何约束的iPhone 6模拟器中的外观示例:

屏幕截图

What are the constraints I need so that it looks okay for all iPhone and iPad sizes and looks like it does in the storyboard? 我需要什么约束才能使它在所有iPhone和iPad尺寸上都可以使用,并像在情节提要中一样? And landscape mode will not be a part of this application, so that will not need to be accounted for. 而且风景模式将不会成为此应用程序的一部分,因此无需考虑。

在此处输入图片说明

You can also use button 1 equal width constraint and button 2 equal width constraint 您还可以使用按钮1等宽约束和按钮2等宽约束

For more details http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1 有关更多详细信息,请访问http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1

在此处输入图片说明

Which is your requirement??? 您的要求是什么???

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

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