我应该使用 xcassets 还是只更改一张图像的大小以在 iOS 的多个设备上开发?

Should I use xcassets or just change the size of one image to develop on multiple devices in iOS?

我想在我的 UICollectionView 上显示占位符图像,直到单元格从我的服务器获取图像。但是,我想知道是否应该为 Images.xcassests 中的情况 1x、2x 和 3x 提前准备三张不同的图像,或者只准备一个 SVG 文件并在代码中加载图像后处理其大小。

具体来说,如果你采用第一种方法,你的过程是这样的:

let imageView = UIImageView(image: UIImage(named: "PlaceholderImageInXcassets")) // frame is set to the size of the image automatically
self.view.addSubview(imageView)

这是第二种方法:

let imageView = UIImageView(image: UIImage(named: "PlaceholderImage"))
imageView.frame = CGRectMake(0, 0, 128, 128) // alter the frame depending on the size of the device
self.view.addSubview(imageView)

所以这是我的问题:

使用 Image assets 为各种设备加载图像性能更高效,速度更快,并且受到 Apple 本身的鼓励。