ios - iPhone 6 上合适的 UIImage 大小

标签 ios iphone uiimageview uiimage png

我有两个 PNG 文件:

  • 568x320.png
  • 667x375.png

如果我正在创建 UIImageView:

UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"568x320.png"]];

并在 iOS 模拟器中运行 > iPhone 5/5s/6 (iOS 8.1) 图像覆盖全屏(甚至在 iPhone 6 上)。另一方面,如果我正在创建 UIImageView:

UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"667x375.png"]];

并在 iOS 模拟器中运行 > iPhone 6 (iOS 8.1) 图像比屏幕大。怎么了?

附言。我没有使用 Storyboard (一切都以编程方式)

PS2。没有添加约束。

最佳答案

您的项目中是否有合适的 iPhone 6/6+ 启动图像?如果不这样做,模拟器将假定您不支持 iPhone 6。在这种情况下,iPhone 会假定您正在扩展应用程序以在这些平台上运行。因此,当您创建 667x375 图像时,它比 iPhone 假设的“屏幕”大。

这就是尚未更新以支持 iPhone 6/6+ 的应用在实际设备上运行时看起来还不错的样子。

尝试包含适当的默认图像,我相信您的问题会消失。

关于ios - iPhone 6 上合适的 UIImage 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28179159/

相关文章:

iphone - 在旋转的轮 subview 上添加减速动画

ios - 如何在 iOS 上的 UIScrollView 中正确替换 UIImageView 中的图像

ios - UINavigationController 未显示在模态视图 Controller 上

iphone - 如何在iPhone应用程序中以秒为单位设置NSTimer时间间隔

ios - 在进入 for 循环之前是否有一种检查数组大小的简短方法?

iphone - 如何从 CGImage 获取原始像素数据

iphone - 如何阻止自定义 UITableViewCell 背景图像可拉伸(stretch)?

ios - UIImageView.appearance 覆盖了 UISegmentedControl.appearance

ios - 在 Swift 中通过 Storyboard Segue 传递自定义初始化参数

ios - UIView ClipsToBounds 不起作用