मेरे पास संपत्ति फ़ोल्डर के साथ एक बंडल है। मैं UIImage(named: "drop_arrow", inBundle: bundle, compatibleWithTraitCollection: nil)
का उपयोग कर (ठीक है, यह तेजी से है 3 बराबर)एक बंडल से संपत्ति फ़ोल्डर से छवियों को लोड करना
path = Bundle.main.path(forResource: "LiveUI", ofType: "bundle")
if path != nil { // path with bundle is found
let bundle: Bundle = Bundle.init(path: path!)! // bundle is there
let image: UIImage? = UIImage(named: "HomePlayButton", in: bundle, compatibleWith: nil)
// HomePlayButton exists in the bundle/asset folder
// but image is nil
}
यह मेरा परियोजना संरचना है के बारे में ढेर पर सभी जवाब पढ़ा है:
आप कोड के साथ किसी भी समस्या को देख सकते हैं/परियोजना की संरचना?
अद्यतन! ... छवि सार्वभौमिक रूप में सभी प्रस्तावों के लिए निर्धारित है:
इस छवि को बंडल नाम 'UIImage (नाम: "yourbundlefile.bundle/HomePlayButton.png") के साथ आज़माएं! ' –