xcode UIImage imageWithXAssets

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19294589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:04:11  来源:igfitidea点击:

UIImage imageWithXAssets

objective-cxcodeuiimagexcasset

提问by Sagar R. Kothari

Assume I have two assets in my project or I may have even more assets under my project.

假设我的项目中有两个资产,或者我的项目下可能有更多资产。

Multiple Assets


Name of image

多种资产


图片名称

  • Question 1: I can have multiple assets in one project & that is valid, correct?
  • Question 2: What if I set same name to an image-set in different xcode-assets? Example. "AppIcon" exists in AppImages.xcassetsand 01 ConsumerSelectionVCtr.xcassets. Why compiler is not showing me errors for same image-set in multiple xcassets.
  • Question 3: How to load an image from xcassets?
  • Question 4: Is it preferable to use xcassets for all images in project?
  • 问题 1:我可以在一个项目中拥有多个资产并且有效,对吗?
  • 问题 2:如果我在不同的 xcode-assets 中为图像集设置相同的名称怎么办?例子。“AppIcon”存在于AppImages.xcassets和 中01 ConsumerSelectionVCtr.xcassets。为什么编译器没有向我显示多个xcassets.
  • 问题 3:如何从 xcassets 加载图像?
  • 问题 4:项目中的所有图像都使用 xcassets 是否更可取?

回答by David Snabel-Caunt

See the Asset Catalog documentation from Apple

请参阅Apple资产目录文档

  1. Yes, and this may help you to organise images
  2. I think one will overwrite the other. Don't give two 'images' the same name
  3. As before, use [UIImage imageNamed:@"LaunchImage"]for example
  4. Yes, apps deployed to iOS 7 can take advantage of an Xcode feature which reduces your app's download time (Xcode does this automatically)
  1. 是的,这可以帮助您组织图像
  2. 我认为一个会覆盖另一个。不要给两个“图像”同名
  3. 和以前一样,使用[UIImage imageNamed:@"LaunchImage"]例如
  4. 是的,部署到 iOS 7 的应用程序可以利用 Xcode 功能减少应用程序的下载时间(Xcode 会自动执行此操作)