遍历Bundle里的图片资源
func bundleTest() {
let mainBundle = Bundle.main.bundlePath
print(mainBundle)
let path2 = ""
let fileManager = FileManager.default
let files = fileManager.subpaths(atPath: mainBundle)
print(files ?? [""])
let array: NSMutableArray = []
if let fileArray = files {
for imageName in fileArray {
if imageName.hasSuffix(".png") || imageName.hasSuffix(".jpg") {
let path = mainBundle.appending(imageName)
array.add(path)
}
}
}
print(array)
}
}