确定默认布局的值

时间:2019-05-29 10:47:26

标签: ios cocoa-touch autolayout

系统根据尺寸类别更改主视图的layoutMargins

像小型iPhone一样,它的剩余值为16;对于X手机,它的剩余值为20

除了向视图控制器询问其layoutMargins (直到显示视图并且在viewDidLoad中为0时才可用),

如何获取更通用的默认值?

我可以查询一般特征

po [UIScreen mainScreen].traitCollection
<UITraitCollection: 0x281de8200; _UITraitNameUserInterfaceIdiom = Phone, _UITraitNameDisplayScale = 2.000000, _UITraitNameDisplayGamut = P3, _UITraitNameHorizontalSizeClass = Compact, _UITraitNameVerticalSizeClass = Regular, _UITraitNameUserInterfaceStyle = 1, _UITraitNameUserInterfaceLayoutDirection = 0, _UITraitNameForceTouchCapability = 1, _UITraitNamePreferredContentSizeCategory = UICTContentSizeCategoryL>

但是如何获取为layoutMargins计算的值?

0 个答案:

没有答案