Asset Catalog: Access images with same name in different folders

前端 未结 1 1072
星月不相逢
星月不相逢 2020-12-08 15:26

There is an images.xcassets in my project, it contains an icons folder and two subfolders (firstFolder, secondFolder) wit

相关标签:
1条回答
  • 2020-12-08 16:01

    Click on each folder in the assets catalog and select Provides Namespace in the Utilities View:

    You will see that the folder then becomes blue and you can see the path to the image above the images.

    You can then access the image like this:

    imageView.image = UIImage(named: "folder1/Image")
    

    or in Objective-C:

    imageView.image = [UIImage imageNamed:@"folder1/Image"];
    
    0 讨论(0)
提交回复
热议问题