简体   繁体   English

使用自动布局自定义每个设备的UIImageView大小

[英]Customize UIImageView size for each device with Auto Layout

I'm only starting to learn Auto Layout and i've hit a wall. 我才刚刚开始学习自动版式,并且碰壁了。

In my Attributes Inspector under PREVIEW, i'm using my main storyboard to preview for every iOS device. 在“预览”下的“属性”检查器中,我使用主故事板预览每个iOS设备。 I'm learning to use auto layout so I can now move an image/label... anywhere on screen I want it to be on all devices. 我正在学习使用自动布局,因此现在可以将图像/标签...在屏幕上的任何位置移动到所有设备上。

However, lets say my UIImageview is 25pixels width by 35 pixels height. 但是,可以说我的UIImageview是25像素宽乘35像素高。 I want to keep that UIImageview size for iPhone 6. However, for iPhone 4s, I want that UIImageview to be 15 Pixels Width by 25 Pixels height and for iPad PRO 50 pixels width by 70 pixels height. 我想为iPhone 6保留UIImageview的大小。但是,对于iPhone 4s,我希望UIImageview的宽度为15像素乘25像素,iPad Pro为50像素乘70像素。

If i'm using a single storyboard and 1 UIImageView, how do I change the standard 25x35 UIImageview pixel to customize its size for every device the size I want it to be? 如果我使用单个故事板和1个UIImageView,如何更改标准的25x35 UIImageview像素,以针对每个设备所需的大小自定义其大小?

Even using size-classes, customizing a single view for every target device is too specific for storyboards with size-classes to be doing such a thing. 即使使用尺寸分类,对于具有尺寸分类的情节提要板,为每个目标设备自定义单个视图也是如此。 In general, what you can do is make your UIImageView a specific width and height for iPhones and then a different width and height for iPads. 通常,您可以做的是将UIImageView设置为iPhone的特定宽度和高度,然后将iPad为不同的宽度和高度。 I believe the size class for iPhones in portrait is compact width and regular height while the size class for iPad is regular height and regular width. 我相信肖像iPhone的尺寸等级是紧凑的宽度和常规的高度,而iPad的尺寸等级是常规的高度和常规的宽度。

You can be specific enough to target 3.5, 4, and 4.7 inch iPhones in landscape with the compact width/compact height combination, but all iPhones in portrait are compact width/regular height 您可以明确地针对具有紧凑宽度/紧凑高度组合的横向3.5、4和4.7英寸iPhone,但所有纵向iPhone均为紧凑宽度/常规高度

https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html

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

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