系统根据尺寸类别更改主视图的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计算的值?