【问题标题】:Handling sizes for iPhone 5, 6, and 6 Plus for height and widths (points)处理 iPhone 5、6 和 6 Plus 的高度和宽度(磅)尺寸
【发布时间】:2014-12-20 01:25:21
【问题描述】:

我在视图控制器中有以下代码:

UITextView *text = [[UITextView alloc] initWithFrame:CGRectMake(5.0, 35.0, 310.0, 90.0)];

[self addSubview:text];

如果 iPhone 的宽度从 5 变为 6 再到 6 Plus,为什么上面的代码在所有这些模拟器中运行时看起来都很好?

我认为宽度是:

iPhone 5: 320
iPhone 6: 375
iPhone 6 Plus: 414

所有模拟器中的视图看起来都不错,但在 iphone 6 和 6 plus 中它们不应该更短吗?

【问题讨论】:

  • 您定义了固定的宽度和高度,为什么要缩短它?
  • 因为手机的宽度大小不同

标签: ios iphone ios7 dimensions points


【解决方案1】:

iphone 尺寸:

iphone 4/4s:

320 X 480

iPhone 5:

320 X 568

iPhone 6:

375 X 667

iphone 6 plus:

414 X 736

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) // iPhone and       iPod touch style UI

#define IS_IPHONE_5_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
#define IS_IPHONE_6_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0f)
#define IS_IPHONE_6P_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0f)
#define IS_IPHONE_4_AND_OLDER_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height < 568.0f)

#define IS_IPHONE_5_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) == 568.0f)
#define IS_IPHONE_6_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) == 667.0f)
#define IS_IPHONE_6P_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) == 736.0f)
#define IS_IPHONE_4_AND_OLDER_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) < 568.0f)

#define IS_IPHONE_5 ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_5_IOS8 : IS_IPHONE_5_IOS7 )
#define IS_IPHONE_6 ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_6_IOS8 : IS_IPHONE_6_IOS7 )
#define IS_IPHONE_6P ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_6P_IOS8 : IS_IPHONE_6P_IOS7 )
#define IS_IPHONE_4_AND_OLDER ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_4_AND_OLDER_IOS8 : IS_IPHONE_4_AND_OLDER_IOS7 )

【讨论】:

  • 它是如何回答问题的?
  • 这些是苹果新设备 iphone 6 和 iphone 6 plus 的新尺寸变化
  • 我已经代表我发现的这些新尺寸新宏更新了我的答案,这对我有用,但不知道也适用于您的场景,希望对您有用:)
  • 但这不是问题的答案,阅读他的问题,这也是我发现的误导
  • 嗯好的,那么他的问题的答案是什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-19
  • 2015-01-31
  • 2015-08-04
  • 2015-02-22
  • 1970-01-01
相关资源
最近更新 更多