Orz Han
Orz Han

Reputation: 83

can not load image from xcassets by using code, but xib can

Previous developer using R.swift to load resources.

And I delete it from Cocoapods, then I using

let image = UIImage.init(named: "testimage") 

to load image from xcassets, and it return nil.

And I load testimage in xib, it works.

I have no idea why I can't load resources from xcassets by using code.

xcassets

code

ib

imageLiteral

Upvotes: 0

Views: 191

Answers (2)

Milan Varasada
Milan Varasada

Reputation: 310

First of all check Your assests file - make sure your given image name is same as store in assests..

second way..

either You can use the image literal easily...

let image = image literal (select Your image)

Upvotes: 1

CristiCh
CristiCh

Reputation: 11774

Just use:

let image = UIImage(named: "imageNameInAssets")

Upvotes: 0

Related Questions