Loading a UIImage from xcassets

ぐ巨炮叔叔 提交于 2019-12-05 17:15:52

You dont have to specify the size of the image in your name. It will automatically load the size that best fits for the device that runs the app. So your code should be.

UIImage *image =  [UIImage imageNamed:@"Default"];

where default is the name of the resource from xcassets, the one you see on the leftside list.

hstdt

Here's the way to get LaunchImage name.

Xcode 5 & Asset Catalog: How to reference the LaunchImage?

Getting image name from info.plist ([[NSBundle mainBundle] infoDictionary])

You should have 2 files:

(1) Default.png (or any other image format) — Non retina

(2) Default@2x.png — Retina

Now, to get this image, you will not have to use @2x at the end of the file name. Use just name of that image asset.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!