ios - 如何在 iOS 中使用图像资源

标签 ios iphone xcasset

我想使用 xcasset 中的启动图像;我已经尝试了一些方法,但无法正常工作。

我有标准的 LaunchImage Assets ,图像文件名为 Default[@2x,...]。使用 [UIImage imageNamed:@"LaunchImage"]; 始终返回 nil。我也尝试过使用 @"Default",但没有结果。

最佳答案

如果您只想在您的应用程序中单独使用编译后的图像:

默认情况下,LaunchImage Assets 会生成以下文件:

LaunchImage-700-Landscape@2x~ipad.png
LaunchImage-700-Landscape~ipad.png
LaunchImage-700-Portrait@2x~ipad.png
LaunchImage-700-Portrait~ipad.png

要找到它们,请使用以下命令:

UIImage* image = [UIImage imageNamed:@"LaunchImage-700-Portrait"];

注意: 下面提到了正确设置 Assets 所需的 3 个步骤。你错过了什么吗?

我的图片:enter image description here

更新启动图像源中的图像: enter image description here

将图像拖放到 LaunchImage Assets 中: enter image description here

关于ios - 如何在 iOS 中使用图像资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27499757/

相关文章:

c# - iOS 使图像适合屏幕

ios - 如何从masterdetailpage中的detailpage推送异步?

iphone - 按下标签栏项目时是否可以重新加载 View ?

uiimage - Auto Scaling 在 Xcode 10 xcasset 图像属性中做什么

ios - 实例方法 'mapView(_:didFailToLocateUserWithError:)'几乎符合可选要求

ios - NSURLSession 线程 : Tracking multiple background downloads

iPhone:如何实现波斯日历?

ios - 无法在 Visual Studio 中保存 .xcasset 文件

ios - 无法使用代码从 xcassets 加载图像,但 xib 可以

IOS7 : Incorrect checksum for freed object