I'm writing a class to build a cocoapods and I want to get the image I placed in Assets.xcassets
. The problem is always getting nil
image. Are there anything I miss?
Here is the directory stucture :
This is what I try to load the Image:
#import "HaloImage.h"
@implementation HaloImage
- (void)showImage {
NSBundle * bundle = [NSBundle bundleForClass:self];
NSURL * bundleUrl = [bundle URLForResource:@"Assets" withExtension:@"bundle"];
self.image = [UIImage imageNamed:bundleUrl.absoluteString];
}
@end
you can use image from asset or main bundle only by name (png file)