iPhone 接口(interface)尺寸

标签 iphone objective-c ios

我在哪里可以获得 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 具有获取标准字体大小的类方法:labelFontSizebuttonFontSizesmallSystemFontSize 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/

相关文章:

ios - 尝试用 replaceOccurrencesOfString :withString:options:range: 改变不可变对象(immutable对象)

ios - 停止 SKAction.applyForce

iphone - 如何在 GCC 和 Xcode 中手动引发编译器错误

iphone - 如何使用 NSUserDefaults 为应用程序创建自动登录设置

objective-c - 每个 ivar 都必须是一个属性吗?

iPhone iOS "face in the hole"这类app,如何将两张图片拼接在一起?

ios - 我可以使用 SpriteKit 在 iOS 上从非矩形区域发射粒子吗?

ios - 使 UIImageView 适合 UIImage

ios - tabbar 没有显示在 secondview Controller 中

ios - iPhone 和 iPod Touch 之间的区别