我在哪里可以获得 iOS 中 UI 元素的系统大小?
例如,
- UIButton 圆角半径,
- UIWindow 大小(我知道它是 320pt,但它有一个常数吗?),
- 系统字体大小,
- 导航栏高度,
- 标签栏高度,
- 状态栏高度等
它们是否有预定义的常量或类似的常量?
最佳答案
UIButton corner radius
我认为没有相应的 API。
UIWindow size (I know it's 320pt, but is there a constant for it?)
您可以通过 [[UIScreen mainScreen] bounds]
获取它。
System font size
UIFont
具有获取标准字体大小的类方法:labelFontSize
、buttonFontSize
、smallSystemFontSize
和 systemFontSize
可用。
Navigation bar height, Tab bar height,
UIView
实例方法 sizeThatFits:
可用于获取它们的默认大小。
Status bar height
您可以通过从 [[UIScreen mainScreen] applicationFrame]
中减去 [[UIScreen mainScreen] bounds]
的高度来隐式获得它。
关于iPhone 接口(interface)尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7790283/