简体   繁体   English

使用Storyboard或xib中的iOS AutoLayout和SizeClass在不同屏幕中可变的视图高度

[英]Variable height of view in different screens with iOS AutoLayout And SizeClass in Storyboard or xib

Steps: 脚步:

1.I use SizeClass "compact width, any height" 1.我使用SizeClass“紧凑的宽度,任何高度”

2.I set the view's height 40px to fit for the 3.5/4.0/4.5/4.7 inch screen 2.我将视图的高度设置为40px以适合3.5 / 4.0 / 4.5 / 4.7英寸屏幕

3.I change SizeClass to "compact width, regular height" 3.我将SizeClass更改为“紧凑宽度,常规高度”

4.I want set the view's height 60px to fit for the 5.5 inch screen 4.我想将视图的高度设置为60像素以适合5.5英寸的屏幕

5.When I run simulator with iphone6+ the view's height is 60px this is right 5.当我使用iphone6 +运行模拟器时,视图的高度为60px,这是正确的

6.When I run simulator with iphone4/iphone5/iphone5s/iphone6 the view's height is 60px but i want 3.5/4.0/4.5/4.7 inch screen is 40px 6,当我使用iphone4 / iphone5 / iphone5s / iphone6运行模拟器时,视图的高度为60px,但我希望3.5 / 4.0 / 4.5 / 4.7英寸的屏幕为40px

How can I realize variable height of view in different screens with AutoLayout And SizeClass in storyboard or xib I want view's height 60px in 5.5 inch screen I want view's height 40px in 3.5/4.0/4.5/4.7 inch screen 我如何在情节提要或Xib中使用AutoLayout和SizeClass在不同的屏幕中实现可变的视图高度,我希望在5.5英寸的屏幕中视图的高度60px在3.5 / 4.0 / 4.5 / 4.7英寸的屏幕中视图的高度40px

You cannot do this via SizeClasses because in portrait, iPhone 6, iPhone 5, and iPhone 4s use the compact horizontal and regular vertical size classes. 您无法通过SizeClasses执行此操作,因为在纵向模式下, iPhone 6,iPhone 5和iPhone 4s使用紧凑的水平尺寸和常规垂直尺寸级别。 So it is the same as iPhone 6 Plus uses the compact horizontal and regular vertical size classes in portrait. 因此,它与iPhone 6 Plus在肖像中使用紧凑的水平尺寸和常规垂直尺寸类相同。 Please, see the following source Adaptivity and Layout 请参阅以下资源适应性和布局

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

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